Autoset constants (Required fields having single valid enum value) Java (OkHttp) Implementation of #16547#16550
Merged
wing328 merged 6 commits intoOpenAPITools:masterfrom Sep 15, 2023
Conversation
…parameter is also marked as required
…parameter is also marked as required
…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
reviewed
Sep 14, 2023
.../openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
Show resolved
Hide resolved
wing328
reviewed
Sep 14, 2023
.../openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
Show resolved
Hide resolved
wing328
reviewed
Sep 14, 2023
modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
Outdated
Show resolved
Hide resolved
…parameter is also marked as required for Java default client.
Member
|
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) |
Member
|
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. |
6 tasks
Member
|
FYI. I've filed #16594 to support constant in default codegen (parameter only) as a starting point. |
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
Created a new property
autosetConstantsand added implementation for Java (OkHttp) client.If
autosetConstantsis 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.shand there is no change in existing code generation if the newautosetConstantsproperty is not set, Therefore there should not be any risk in getting this change merged.