Skip to content

[GO] fix generated variable names when no discriminator is used with 'oneOf'#19183

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
sazapp-spectra:fix_issue_18922
Jul 31, 2024
Merged

[GO] fix generated variable names when no discriminator is used with 'oneOf'#19183
wing328 merged 2 commits intoOpenAPITools:masterfrom
sazapp-spectra:fix_issue_18922

Conversation

@sazapp-spectra
Copy link
Contributor

Fixes #18922. In particular, useOneOfDiscriminatorLookup needs to be true when generating to reproduce the issue; the goal is for the output to match whether it's true or false.

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/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    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*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.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.

@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @lwj5

description: "No Content"
components:
schemas:
Bar:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about adding this new schema/model to modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml (the existing go test spec) instead and then regenerate the samples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done - ./bin/generate-samples.sh ./bin/configs/go-petstore.yaml -- -p useOneOfDiscriminatorLookup=true now reproduces the issue in model_one_of_with_complex_type.go (when the mustache changes are reverted).

@wing328 wing328 added this to the 7.8.0 milestone Jul 18, 2024
- an array of strings variant should end up with the same valid name
whether `useOneOfDiscriminatorLookup` is `true` or `false`
@sazapp-spectra sazapp-spectra requested a review from wing328 July 23, 2024 21:54
@wing328
Copy link
Member

wing328 commented Jul 31, 2024

looks good. let's give it a try

thanks for the PR

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.

[BUG][Go] anyOf with objects and arrays generates uncompilable model

2 participants