Autoset constants (Required fields having single valid enum value)#16761
Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom Oct 16, 2023
Merged
Autoset constants (Required fields having single valid enum value)#16761wing328 merged 2 commits intoOpenAPITools:masterfrom
wing328 merged 2 commits intoOpenAPITools:masterfrom
Conversation
…thon Implementation of OpenAPITools#16547
Member
|
can you please PM me via Slack when you've time to further discuss this PR? |
Member
|
cc @OpenAPITools/generator-core-team as there are changes to default codegen |
Member
|
cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10) |
Member
|
let's go with what you've so far. thanks again for the PR. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Code Changes
Partial implementation of #16547
If
autosetConstantsis set to True, the generated code by Python generator will hardcode values for any Header / Query Param which is marked as required and can only have a single valid enum value.The single valued required enum i.e. The constant param will be removed from the method signature.
Also, Sight refactoring of the code pushed in #16550
The Code to handle constants can be shared by all the generators.
Testing
A test case has been added that asserts that if
autosetConstantsis set to true then the constant key/value pair is being set in the generated code.I've run
./bin/generate-samples.shand there is no change in existing code generation if the new autosetConstants property is not set, Therefore there should not be any risk in getting this change merged.