Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException for anyOf contains primitive array type #4474

Closed
rudibatt opened this issue Sep 6, 2023 · 1 comment
Closed

NullPointerException for anyOf contains primitive array type #4474

rudibatt opened this issue Sep 6, 2023 · 1 comment
Assignees

Comments

@rudibatt
Copy link

rudibatt commented Sep 6, 2023

With a model that contains a property that uses anyOf to reference primitive array types, the ModelResolver runs into a NPE/NullPointerException.

Truncated Model that causes the issue:

public class Document {
	@Schema(
			anyOf = {
			 	  Boolean[].class,
				  Integer[].class,
				  Long[].class,
				  Double[].class,
				  String[].class,
			})
	public Map<String, Object> data = new HashMap<>();
}

Exception:

[ERROR] Error resolving API specification
java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getName()" because "anyOfRef" is null
    at io.swagger.v3.core.jackson.ModelResolver.lambda$resolve$8 (ModelResolver.java:925)
    at java.util.ArrayList.forEach (ArrayList.java:1511)
    at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:923)
    at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:97)
    at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:445)
    at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:97)
    at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:706)
    at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:97)
    at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:477)
    at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:97)
    at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:706)
    at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:97)
    at io.swagger.v3.core.converter.ModelConverters.resolveAsResolvedSchema (ModelConverters.java:153)
    at io.swagger.v3.core.util.ParameterProcessor.applyAnnotations (ParameterProcessor.java:69)
    at io.swagger.v3.jaxrs2.DefaultParameterExtension.extractParameters (DefaultParameterExtension.java:117)
    at io.swagger.v3.jaxrs2.Reader.getParameters (Reader.java:1520)
    at io.swagger.v3.jaxrs2.Reader.read (Reader.java:567)
    at io.swagger.v3.jaxrs2.Reader.read (Reader.java:196)
    at io.swagger.v3.jaxrs2.Reader.read (Reader.java:224)
    at io.swagger.v3.oas.integration.GenericOpenApiContext.read (GenericOpenApiContext.java:642)
    at io.swagger.v3.plugin.maven.SwaggerMojo.execute (SwaggerMojo.java:84)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
@frantuma
Copy link
Member

fixed by #4640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants