Created by: mugioka
Closes https://github.com/OpenAPITools/openapi-generator/issues/13588
Hi team.
The following error occurred while generating a k6 scenario from oas using openapi-generator-cli version 6.2.0.
Exception in thread "main" java.lang.RuntimeException: Could not process model 'CommonSiteLink'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:518)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:912)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:465)
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 "io.swagger.v3.oas.models.media.Schema.getDiscriminator()" because "childSchema" is null
at org.openapitools.codegen.DefaultCodegen.addImport(DefaultCodegen.java:5497)
at org.openapitools.codegen.DefaultCodegen.updateModelForComposedSchema(DefaultCodegen.java:2633)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2963)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1291)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:513)
... 4 more
This error is occurred if allDefinitions is null or allDefinitions.get(ref) returned null.
Therefore i added null check of the childSchema to the if statement.
This error was generated by https://github.com/OpenAPITools/openapi-generator/pull/12798.
The release that incorporates this PR appears to be 6.1.0, so versions above 6.1.0 may have the above error.
Signed-off-by: mugioka okamugi0722@gmail.com
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master(6.1.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks) -
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.