Skip to content

Autoset constants (Required fields having single valid enum value) Java (OkHttp) Implementation of #16547#16550

Merged
wing328 merged 6 commits intoOpenAPITools:masterfrom
prashant-pant:autoset-constants
Sep 15, 2023
Merged

Autoset constants (Required fields having single valid enum value) Java (OkHttp) Implementation of #16547#16550
wing328 merged 6 commits intoOpenAPITools:masterfrom
prashant-pant:autoset-constants

Conversation

@prashant-pant
Copy link
Contributor

Code changes

Partial implementation of #16547
Created a new property autosetConstants and added implementation for Java (OkHttp) client.
If autosetConstants is set to True, the generated code will hardcode values for any Header / Query / Cookie Param which is marked as required and can only have a single valid enum value.
The constant params will be removed from the method signature of the API.

Testing

A testcase has also been added to validate Header value is hardcoded if above is true.
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.

…parameter is also marked as required for Java default client.
…parameter is also marked as required for Java default client.
…parameter is also marked as required for Java default client.
…parameter is also marked as required for Java default client.
@wing328
Copy link
Member

wing328 commented Sep 15, 2023

FYI @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)

@wing328
Copy link
Member

wing328 commented Sep 15, 2023

as discussed we'll remove the option in the documentation for the time being as we will need to make some improvement in the default codegen to handle constant. i'll file a follow-up PR later to clean up the option.

@wing328 wing328 merged commit 4b87606 into OpenAPITools:master Sep 15, 2023
@wing328 wing328 mentioned this pull request Sep 15, 2023
6 tasks
@wing328
Copy link
Member

wing328 commented Sep 15, 2023

FYI. I've filed #16594 to support constant in default codegen (parameter only) as a starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants