New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java][Native]Add option to use the builder pattern for API parameters #5961
[Java][Native]Add option to use the builder pattern for API parameters #5961
Conversation
@@ -94,7 +95,12 @@ public class {{{classname}}}Example { | |||
{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} | |||
{{/allParams}} | |||
try { | |||
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} | |||
{{^vendorExtensions.x-group-parameters}} | |||
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}{{#hasParams}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you break the lines like for instance
{{^vendorExtensions.x-group-parameters}}
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/vendorExtensions.x-group-parameters}}
{{#vendorExtensions.x-group-parameters}}
{{#hasParams}}
API{{operationId}}Request request = API{{operationId}}Request.newBuilder(){{#allParams}}
.{{paramName}}({{paramName}}){{/allParams}}
.build();
{{/hasParams}}
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}});
{{/vendorExtensions.x-group-parameters}}
{{#returnType}}System.out.println(result);{{/returnType}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may add extra empty line for {{^vendorExtensions.x-group-parameters}}
case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO having an extra empty line in auto generated source code is alright if it can make the maintenance easier. Also, I don't know how about the java clients but the ruby one has the option to run a linter afterwards to take care of such things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't result in empty lines if the start tag and end tag are aligned properly. Ref: https://github.com/samskivert/jmustache#newline-trimming
|
||
{{^vendorExtensions.x-group-parameters}} | ||
> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) | ||
{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do both {{/vend..
and {{#ven..
need to be on the same line?
95e835f
to
4b4a097
Compare
4b4a097
to
5e29e3f
Compare
bca7c69
to
ea39a73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some tests, which passed via https://cloud.drone.io/OpenAPITools/openapi-generator/8961
Ths PR added the option to build API requests using builder pattern for Client-Java-Native based on the request
It includes the changes below:
update the template of API
update the template of README
add modified template of api test under native
add modified template of api doc under native
update Petstore samples for native
fixed build error with null async return
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.@wing328 @cbornet @jeff9finger @bbdouglas @sreeshas @jfiala @lukoyanov @karismann @Zomzog @lwlee2608 @bkabrda @jfeltesse-mdsol @jcarres-mdsol