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

Malformed Spec Causes NPE #1685

Closed
ricekot opened this issue Mar 29, 2022 · 4 comments
Closed

Malformed Spec Causes NPE #1685

ricekot opened this issue Mar 29, 2022 · 4 comments
Assignees

Comments

@ricekot
Copy link

ricekot commented Mar 29, 2022

Parsing the following spec:

{
   "notswagger:"x.0"
}

results in an NPE instead of returning a list of errors.

This may be happening because out.getOpenAPI() is nullable at:

new ResolverFully(options.isResolveCombinators()).resolveFully(out.getOpenAPI());

Stack trace:

java.lang.NullPointerException
	at io.swagger.v3.parser.util.ResolverFully.resolveFully(ResolverFully.java:61)
	at io.swagger.v3.parser.converter.SwaggerConverter.readResult(SwaggerConverter.java:114)
	at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:92)
...
@gracekarina
Copy link
Contributor

Hi @ricekot thanks for reporting this issue, we have added a pr with a test and the fix. Please reopen if this keep happening.

@gracekarina gracekarina self-assigned this Mar 30, 2022
@ricekot
Copy link
Author

ricekot commented Mar 31, 2022

It seems that the NPE is resolved, but the error is still not reported. The spec I provided above is deliberately malformed, and the SwaggerParserResult object should contain the following (or similar) error message:

Unexpected character ('x' (code 120)): was expecting a colon to separate field name and value
 at [Source: (String)"{
  "notswagger:"x.0"
}

This is printed to the output but not returned in the error messages list.

@gracekarina
Copy link
Contributor

@ricekot please check, I have added a solution for the messages don't get lost in the process of conversion.

@ricekot
Copy link
Author

ricekot commented Apr 5, 2022

Yes, thank you, this issue is resolved now.

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