[Java][okhttp-gson] Add option to employ builders for API requests#1341
[Java][okhttp-gson] Add option to employ builders for API requests#1341wing328 merged 23 commits intoOpenAPITools:masterfrom
Conversation
docs/generators/java.md
Outdated
There was a problem hiding this comment.
I would set it to true by default
|
As always, I'm reluctant to have too many options. So I would prefer to always generate the builder, keep the constructors |
|
@cbornet Thanks for your feedback. I agree that too many options can be undesirable. Perhaps the option can be removed in the next major release (to only generate the builder style)? Otherwise, I can incorporate your proposed changes. This would require the public builder method name to be changed, however, to not conflict with one of the current method names. |
|
@Kiran-Sivakumar @cbornet FYI. next major version 4.x (with breaking changes) will be released before year-end so we can clean up the options as part of the 4.x release later. |
|
Ok, so should I keep it as an option for this PR, changing it to be true by default, and file another PR against 4.x in a few weeks that removes the option entirely? |
|
@Kiran-Sivakumar I've other ideas. Let me review and get back to you by Thursday. |
|
@Kiran-Sivakumar instead of using This will avoid another option and make it possible to enable group parameters per operation. |
|
I see. What if you wanted to enable builders for all operations for a cohesive API? Is there an easy way to apply group parameters to all of them? |
|
@Kiran-Sivakumar similar to what we did for Does it sound good to you? |
|
Oh great. Yes, this sounds good to me. I'll incorporate your feedback. |
fe4d53a to
43e6c70
Compare
|
@Kiran-Sivakumar I've filed #1405 to add top level x-group-parameters support. |
43e6c70 to
f6b3f68
Compare
|
@Kiran-Sivakumar thanks for the PR, which has been included in the v3.3.4 release: https://twitter.com/oas_generator/status/1068772409795207168 |
…penAPITools#1341) * Generate APIs that use the builder pattern * Add option to use builders for API requests * Fix template spacing * Add new sample-generation script and generated samples * Update docs * Add new sample-generation script for Windows * Replace config option with vendor extension * Remove useBuildersForApiRequests config option * Remove builders sample-generation scripts * Replace config option with vendor extension in api_test template * Remove okhttp-gson-requestBuilders sample * Rename x-builders-for-api-requests to x-group-parameters * Add modified api_doc.mustache under okhttp-gson resources * Add modified README.mustache under okhttp-gson resources * Update petstore samples * Fix FakeApiTest.java in petstore samples * Add whitespace to rerun checks * Remove whitespace to rerun tests * Fix FakeApiTest.java in parcelable petstore sample * Update versions in samples * Update versions in samples
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,3.4.x,4.0.x. Default:master.@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger
Description of the PR
fix #1217
This PR (filed against branch 3.4.x) adds the option to generate APIs of the form shown in the proposed solution in the above issue. This makes generated okhttp-gson clients much nicer to use, especially in cases involving unused optional parameters. The hope is to implement a similar solution for all Java generators in the future, so that generated Java clients aren't frustrating to use.
Changes:
I also ran the original shell scripts under
./bin/to ensure that absolutely nothing changes in the existing petstore samples when the "useBuildersForApiRequests" option is disabled.