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

NPE in io.swagger.v3.core.jackson.ModelResolver when trying to retrieve /v3/api-docs #486

Closed
planetf1 opened this issue Mar 11, 2020 · 3 comments

Comments

@planetf1
Copy link

planetf1 commented Mar 11, 2020

After launching my springdoc-enabled application, I get an exception when attempting to load the swagger ui api definition:

2020-03-11 11:41:19.898 ERROR 58508 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null
	at io.swagger.v3.core.jackson.ModelResolver$GeneratorWrapper.process(ModelResolver.java:1110) ~[swagger-core-2.1.1.jar!/:2.1.1]
	at io.swagger.v3.core.jackson.ModelResolver$GeneratorWrapper.access$100(ModelResolver.java:976) ~[swagger-core-2.1.1.jar!/:2.1.1]
	at io.swagger.v3.core.jackson.ModelResolver$GeneratorWrapper$2.processAsProperty(ModelResolver.java:1032) ~[swagger-core-2.1.1.jar!/:2.1.1]
	at io.swagger.v3.core.jackson.ModelResolver$GeneratorWrapper.processJsonIdentity(ModelResolver.java:1092) ~[swagger-core-2.1.1.jar!/:2.1.1]
	at io.swagger.v3.core.jackson.ModelResolver.resolve(ModelResolver.java:291) ~[swagger-core-2.1.1.jar!/:2.1.1]
	at org.springdoc.core.converters.AdditionalModelsConverter.resolve(AdditionalModelsConverter.java:49) ~[springdoc-openapi-common-1.2.33.jar!/:1.2.33]
	at org.springdoc.core.converters.PropertyCustomizingConverter.resolve(PropertyCustomizingConverter.java:42) ~[springdoc-openapi-common-1.2.33.jar!/:1.2.33]

The full log is at https://gist.github.com/1f461620f990b1f1386314ae4298d4ee

I tried to follow the simple approach of mostly using defaults (I get the same error without application.properties), but am unsure why I get the NPE when trying to access the api docs.

I of course hit the same issue when the maven plugin runs integration tests.

Spring boot - 2.2.5.RELEASE
sprindoc-openapi - springdoc-openapi-ui @ 1.2.33

I don't currently have simplified sample code

the project was previously using springfox, but just as you summarised in the project intro, that project is not seeing suitable support any more so were were interesting in trying springdocs instead

The primary changes made to the module to support springdocs was to add

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
        </dependency>

We also enforce the dependency version in our top level pom (using your latest version).

All springfox changes, including the dependencies, doclets, @EnableSwagger2 annotations were removed.

Our project: https://github.com/odpi/egeria
A PR with my springfox removal/adding springdoc -> odpi/egeria#2729

**

@bnasslahsen
Copy link
Contributor

Hi @planetf1,

This issue is not related to springdoc-openapi but to swagger-core project.
It happens on classes with cyclic reference using @JsonIdentityInfo annotation.

You have a workaround described on the link below:

@planetf1
Copy link
Author

Thanks for the super helpful response. Have it working now :-)

@daniel-schel
Copy link

I have created a fix for this issue in the following PR: swagger-api/swagger-core#3908

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