Bug Report Checklist
Description
After upgrading from v7.12.0 to v7.13.0 of openapi-generator-cli code generation of one of our OpenAPIs throws the following exception:
Exception: Cannot invoke "java.util.Map.get(Object)" because "actualComponentsExamples" is null
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1606)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1474)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:663)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1296)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because "actualComponentsExamples" is null
at org.openapitools.codegen.utils.ExamplesUtils.unaliasExamples(ExamplesUtils.java:75)
at org.openapitools.codegen.DefaultCodegen.unaliasExamples(DefaultCodegen.java:2355)
at org.openapitools.codegen.DefaultCodegen.fromResponse(DefaultCodegen.java:5028)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:4685)
at org.openapitools.codegen.languages.AbstractJavaCodegen.fromOperation(AbstractJavaCodegen.java:2225)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1574)
... 6 more
It's not related to a particular spec, I've tested with 2 different languages (jaxrs-spec and go) and both gave the same exception. While creating the reproducer I noticed that removing the path parameter from the operation path, and thus also from its reference, made the NPE disappear:
So the following throws the NPE:
/reproducers/{id}:
$ref: "operations.yaml#/paths/~1reproducers~1{id}"
but this doesn't:
/reproducers:
$ref: "operations.yaml#/paths/~1reproducers"
openapi-generator version
OpenAPI declaration file content or url
https://gist.github.com/clone1612/e9ca124ca323843d0175c67a4890d5ee
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate -i /local/reproducer.yaml -g jaxrs-spec -o /local/out/jaxrs-spec
Steps to reproduce
- Check out the linked gist and make sure all 3 files are located within the same directory
- Run the docker cli command
Related issues/PRs
The ExampleUtils class that throws the NPE was introduced in #20933 so might be related to that PR
Suggest a fix
/
Bug Report Checklist
Description
After upgrading from v7.12.0 to v7.13.0 of
openapi-generator-clicode generation of one of our OpenAPIs throws the following exception:It's not related to a particular spec, I've tested with 2 different languages (jaxrs-spec and go) and both gave the same exception. While creating the reproducer I noticed that removing the path parameter from the operation path, and thus also from its reference, made the NPE disappear:
So the following throws the NPE:
but this doesn't:
openapi-generator version
OpenAPI declaration file content or url
https://gist.github.com/clone1612/e9ca124ca323843d0175c67a4890d5ee
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate -i /local/reproducer.yaml -g jaxrs-spec -o /local/out/jaxrs-specSteps to reproduce
Related issues/PRs
The
ExampleUtilsclass that throws the NPE was introduced in #20933 so might be related to that PRSuggest a fix
/