-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG][CLI] crash when evaluating definitions without parameters #7453
Comments
I'll leave this for my findings while digging into this It looks like when this is evaluated, the result.messages property is null and this is what causes the NPE. SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options); |
The root cause of this issue seems to come from swagger-parser. It will return null for messages and throw a NPE. I think what we can do is add some decent error handling for when this kind of error does occur. |
swagger-parser has the potential to return null for messages which will throw NPE on initialization of the validationMessages hashset. rather that allow this to happen we will assume that a null message collection represents an empty collection and continue. Fixes OpenAPITools#7453
I have added a PR that will not fix this, but will make it much more obvious what has gone wrong. |
swagger-parser has the potential to return null for messages which will throw NPE on initialization of the validationMessages hashset. rather that allow this to happen we will assume that a null message collection represents an empty collection and continue. Fixes #7453
Bug Report Checklist
Description
When you provide openapi-generator an openapi definition that includes a url with path variables, but no defined parameters, it will throw a null pointer exception.
openapi-generator version
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
https://github.com/codymikol/openapi-generator-kotlin-bug-demo/blob/master/generated-openapi-spec.json
Generation Details
This seems to happen regardless of generator-name, and the only other CLI options I am providing are the input-spec and output.
Steps to reproduce
I have created a minimal repro repository over here
this includes a shell script with all of the exact steps that I took. The generated openapi spec is hardcoded in the repo, but I have also included a minimal Spring project that generates the spec via springfox 3 if you'd like to generate that yourself.
Note that the script uses the latest published openapi-generator and will need some tweaking to point at your own build. I have tested with both and they have the same result
Related issues/PRs
I did a search, but found nothing similar.
Suggest a fix
I plan on looking into this myself, this is mostly to help document the issue in case I end up not having enough time. Any suggestions would be great.
The text was updated successfully, but these errors were encountered: