[BUG][CLI] crash when evaluating definitions without parameters
Created by: codymikol
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
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.
Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.HashSet.<init>(HashSet.java:120)
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:464)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:507)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:423)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
openapi-generator version
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
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.