-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[codegen] change x-oneOf-name to x-one-of-name. Consistency with naming conventions and x-all-of-name #5820
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
39da276
change x-oneOf-name to x-one-of-name.
sebastien-rosset b70a4ea
Add code comments
sebastien-rosset 18b5298
Add code comments
sebastien-rosset 7ab1139
sync from master
sebastien-rosset 4f550a9
Merge branch 'master' of github.com:CiscoM31/openapi-generator into x…
sebastien-rosset 32d2a09
Merge branch 'master' of github.com:CiscoM31/openapi-generator into x…
sebastien-rosset f8cd333
Merge branch 'master' of github.com:CiscoM31/openapi-generator into x…
sebastien-rosset c9893e5
Merge branch 'master' of github.com:CiscoM31/openapi-generator into x…
sebastien-rosset File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 , it would be good to explain how this field is used. In other words, the 'x-one-of-name' extension exists for a reason. Why should an OAS author set this extension? What is the value of setting that extension?
Without
x-one-of-name
, the generated oneOf name for the schema below would beOneOf<Animal,Plant,Fungus,Bacteria>
. It would be helpful to document how this influences the generated output.Is it ok to set the value of x-one-of-name to the same value as the container? That's typically a good name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's step back for a second. Why not update LivingOrganism if the users want to have complete control of the naming?
In other words, x-one-of-name seems to be redundant if we can simply use the container (schema) name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I totally agree the the container name would be the best default name. I was wondering why that was not the case. I suspect this is because in ModelUtils, the functions typically don't have access to anything other than the local schema passed as an argument, which makes it harder to access elements like the container schema (which would be needed to get the name of the container schema)
Here the use of x-one-of-name is just a workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because the default
toOneOfName
is used: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.javaI'll do some tests to try to figure out the "correct" way to override this method in the language generator so that we don't need to use x-one-of-name if possible.