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 ModelResolver #3311

Closed
mads-b opened this issue Oct 1, 2019 · 6 comments
Closed

NpE in ModelResolver #3311

mads-b opened this issue Oct 1, 2019 · 6 comments

Comments

@mads-b
Copy link

mads-b commented Oct 1, 2019

Hello, I'm stuck at Swagger API 2.0 because upgrading the config to generate openapi v.3.0 (running swagger-core 2.0.9) results in the following exception when running:

[ERROR] Error resolving API specification java.lang.NullPointerException at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:320) at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:90) at io.swagger.v3.core.jackson.ModelResolver.lambda$resolve$1 (ModelResolver.java:614) at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:277) at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:90) at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:622) at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:90) at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:395) at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:90) at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:363) at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:90) at io.swagger.v3.core.jackson.ModelResolver.resolve (ModelResolver.java:622) at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve (ModelConverterContextImpl.java:90) at io.swagger.v3.core.converter.ModelConverters.resolveAsResolvedSchema (ModelConverters.java:112) at io.swagger.v3.jaxrs2.Reader.parseMethod (Reader.java:1020) at io.swagger.v3.jaxrs2.Reader.parseMethod (Reader.java:818)

Any ideas what's wrong/any fixes/workarounds? I've gotten quite "creative" using Jackson in this project, and in the sister project it works fine, so I suspect this is related to that rather creative bean that references a list of itself alongside having a @JsonUnwrapped member?

@frantuma
Copy link
Member

frantuma commented Oct 1, 2019

Can you share the class/method causing the issue?

@mads-b
Copy link
Author

mads-b commented Oct 1, 2019

At least this is my prime suspect.. Might be that links field as well; It has a polymorphic child, but that is not exactly uncommon in the Jackson world:

Links is a bean that has a @JsonValue method that returns a map, where the values are a superclass with two implementations.
HalBean.txt

@frantuma
Copy link
Member

frantuma commented Oct 1, 2019

A possible co-culprit might be your shared bean using 1.5/x version (swagger/OpenAPI 2.0) of annotations, swagger-core 2.x supports a different set of annotations. You would need to update the bean to use the new set.

Additionally JsonSerialize.As is not yet supported in 3.0, see also #3288 (support should be part of upcoming release)

@mads-b
Copy link
Author

mads-b commented Oct 1, 2019

We can rule out both those. The sister project I talked about uses that @JsonSerialize.as statement in all beans and somehow works (is that a fluke then, perhaps?), in addition I've tried porting all the beans over to the new annotation style without luck; It fails even without any openAPI annotations..

frantuma added a commit that referenced this issue Oct 1, 2019
frantuma added a commit that referenced this issue Oct 1, 2019
frantuma added a commit that referenced this issue Oct 1, 2019
@frantuma
Copy link
Member

frantuma commented Oct 1, 2019

playing a bit around for some reason this seemed to happen in scenarios with both JsonUnwrapped and Optional involved. Update in #3313 fixes the NPE, this is available in latest 2.0.10-SNAPSHOT and upcoming release.

@mads-b
Copy link
Author

mads-b commented Oct 1, 2019

That's awesome! Lightning fast :-)

Thank you so much. I suppose I have a great deal to do very soon in order to port all the annotations over to v3..

@mads-b mads-b closed this as completed Oct 2, 2019
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

2 participants