Skip to content

Skip import of allOf composition schema#12798

Merged
wing328 merged 5 commits intomasterfrom
fix-allof-import
Jul 10, 2022
Merged

Skip import of allOf composition schema#12798
wing328 merged 5 commits intomasterfrom
fix-allof-import

Conversation

@wing328
Copy link
Copy Markdown
Member

@wing328 wing328 commented Jul 8, 2022

Skip import of allOf composition schema (without discriminator)

Only javascript, python generator keeps the old behaviour.

FYI @OpenAPITools/generator-core-team

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:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    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 ./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.

@wing328 wing328 marked this pull request as ready for review July 10, 2022 02:04
@wing328 wing328 added this to the 6.1.0 milestone Jul 10, 2022
@wing328 wing328 merged commit f242b5e into master Jul 10, 2022
@wing328 wing328 deleted the fix-allof-import branch July 10, 2022 06:58
mugioka added a commit to mugioka/openapi-generator that referenced this pull request Oct 4, 2022
…lName).

Hi team.

The following error occurred while generating a k6 scenario from oas using openapi-generator-cli version 6.2.0.

```log
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 childSchema to if statement.

This error was generated by OpenAPITools#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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant