Skip to content

Autoset constants (Required fields having single valid enum value)#16761

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
prashant-pant:autoset-constants
Oct 16, 2023
Merged

Autoset constants (Required fields having single valid enum value)#16761
wing328 merged 2 commits intoOpenAPITools:masterfrom
prashant-pant:autoset-constants

Conversation

@prashant-pant
Copy link
Copy Markdown
Contributor

@prashant-pant prashant-pant commented Oct 8, 2023

Code Changes

Partial implementation of #16547
If autosetConstants is 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 autosetConstants is set to true then the constant key/value pair is being set in the generated code.
I've run ./bin/generate-samples.sh and 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.

@wing328
Copy link
Copy Markdown
Member

wing328 commented Oct 15, 2023

can you please PM me via Slack when you've time to further discuss this PR?

@wing328
Copy link
Copy Markdown
Member

wing328 commented Oct 16, 2023

cc @OpenAPITools/generator-core-team as there are changes to default codegen

@wing328 wing328 changed the title Autoset constants (Required fields having single valid enum value) Py… Autoset constants (Required fields having single valid enum value) Oct 16, 2023
@wing328
Copy link
Copy Markdown
Member

wing328 commented Oct 16, 2023

cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)

@wing328
Copy link
Copy Markdown
Member

wing328 commented Oct 16, 2023

let's go with what you've so far. thanks again 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.

2 participants