Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling golang client generation for oneOf with no discriminator and useOneOfDiscriminatorLookup is true #11178

Merged
merged 1 commit into from
Jan 17, 2022

Conversation

kandaaaaa
Copy link
Contributor

@kandaaaaa kandaaaaa commented Dec 22, 2021

Trying to address issue #7961

The idea of the fix is we use the same code of useOneOfDiscriminatorLookup(false) of the condition useOneOfDiscriminatorLookup(true) and discriminator is not defined.

Validation:

  1. Have oneOf without discriminator in the openapi spec
  2. Use useOneOfDiscriminatorLookup: true to generate golang client
  3. Generated code can be compiled and the code will unmarshal each struct

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 (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@ph4r5h4d

@wing328
Copy link
Member

wing328 commented Dec 29, 2021

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328 wing328 added this to the 5.3.1 milestone Dec 29, 2021
@wing328
Copy link
Member

wing328 commented Dec 29, 2021

Please also merge/rebase the latest master into your branch/repo as most of the changes (sample update) have been already done in the master of the official branch.

@wing328 wing328 modified the milestones: 5.3.1, 5.4.0 Dec 29, 2021
@kandaaaaa kandaaaaa force-pushed the master branch 2 times, most recently from eb30f65 to 51d41f9 Compare January 10, 2022 15:47
@kandaaaaa
Copy link
Contributor Author

@wing328 done, please review

…to true, we generated as useOneOfDiscriminatorLookup false
@wing328
Copy link
Member

wing328 commented Jan 17, 2022

Tested locally and the result is good. Thanks for the PR.

@wing328 wing328 merged commit 915af3a into OpenAPITools:master Jan 17, 2022
cachescrubber pushed a commit to cachescrubber/openapi-generator that referenced this pull request Jan 20, 2022
…to true, we generated as useOneOfDiscriminatorLookup false (OpenAPITools#11178)
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.

None yet

2 participants