From fecf399db1f18b37c4279cf47cbd1a3c622e9e00 Mon Sep 17 00:00:00 2001 From: Michael Kourlas Date: Mon, 4 May 2020 13:43:08 -0400 Subject: [PATCH 1/3] Update generators for 3.0.0 --- .../v3/generators/DefaultCodegenConfig.java | 3 + .../resources/handlebars/Java/api.mustache | 73 ++++++ .../Java/libraries/jersey2/api.mustache | 73 ++++++ .../Java/libraries/okhttp-gson/api.mustache | 233 +++++++++++++++++- 4 files changed, 372 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index 703f0086be..85eca275ef 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -2112,6 +2112,9 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation // todo: this segment is only to support the "older" template design. it should be removed once all templates are updated with the new {{#contents}} tag. bodyParams.add(bodyParam.copy()); allParams.add(bodyParam); + if (body.getRequired() != null && body.getRequired()) { + requiredParams.add(bodyParam.copy()); + } } else { boolean alreadyAdded = false; for (Schema usedSchema : foundSchemas) { diff --git a/src/main/resources/handlebars/Java/api.mustache b/src/main/resources/handlebars/Java/api.mustache index d208b6856f..28a891ef77 100644 --- a/src/main/resources/handlebars/Java/api.mustache +++ b/src/main/resources/handlebars/Java/api.mustache @@ -41,6 +41,79 @@ public class {{classname}} { {{#operation}} {{#contents}} + {{#hasOptionalParams}} + public static class {{operationIdCamelCase}}Optionals { + {{#allParams}}{{^required}} + public {{{dataType}}} {{paramName}}() { + return this.{{paramName}}; + } + + public {{operationIdCamelCase}}Optionals {{paramName}}({{{dataType}}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + private {{{dataType}}} {{paramName}} = null; + {{/required}}{{/allParams}} + } + {{/hasOptionalParams}} + + {{#hasOptionalParams}} + /** + * {{summary}} + * {{notes}} + {{#requiredParams}} + * @param {{paramName}} {{description}} (required) + {{/requiredParams}} + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}) throws ApiException { + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + + /** + * {{summary}} + * {{notes}} + {{#requiredParams}} + * @param {{paramName}} {{description}} (required) + {{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call. + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}Opts({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals) throws ApiException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + {{/hasOptionalParams}} + /** * {{summary}} * {{notes}} diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache index 3f21d85245..99e6e7fa6c 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache @@ -40,6 +40,79 @@ public class {{classname}} { {{#operation}} {{#contents}} + {{#hasOptionalParams}} + public static class {{operationIdCamelCase}}Optionals { + {{#allParams}}{{^required}} + public {{{dataType}}} {{paramName}}() { + return this.{{paramName}}; + } + + public {{operationIdCamelCase}}Optionals {{paramName}}({{{dataType}}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + private {{{dataType}}} {{paramName}} = null; + {{/required}}{{/allParams}} + } + {{/hasOptionalParams}} + + {{#hasOptionalParams}} + /** + * {{summary}} + * {{notes}} + {{#requiredParams}} + * @param {{paramName}} {{description}} (required) + {{/requiredParams}} + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}) throws ApiException { + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + + /** + * {{summary}} + * {{notes}} + {{#requiredParams}} + * @param {{paramName}} {{description}} (required) + {{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call. + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}Opts({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals) throws ApiException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + {{/hasOptionalParams}} + /** * {{summary}} * {{notes}} diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache index eb25fa7d62..d7ff6562de 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache @@ -64,6 +64,73 @@ public class {{classname}} { {{#operation}} {{#contents}} + {{#hasOptionalParams}} + public static class {{operationIdCamelCase}}Optionals { + {{#allParams}}{{^required}} + public {{{dataType}}} {{paramName}}() { + return this.{{paramName}}; + } + + public {{operationIdCamelCase}}Optionals {{paramName}}({{{dataType}}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + private {{{dataType}}} {{paramName}} = null; + {{/required}}{{/allParams}} + } + {{/hasOptionalParams}} + + {{#hasOptionalParams}} + /** + * Build call for {{operationId}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}} + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public com.squareup.okhttp.Call {{operationId}}Call({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + return {{operationId}}Call({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}, {{/allParams}}progressListener, progressRequestListener); + } + + /** + * Build call for {{operationId}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call. + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public com.squareup.okhttp.Call {{operationId}}OptsCall({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + return {{operationId}}Call({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}, {{/allParams}}progressListener, progressRequestListener); + } + {{/hasOptionalParams}} + /** * Build call for {{operationId}}{{#parameters}} * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/parameters}} @@ -78,7 +145,7 @@ public class {{classname}} { */ public com.squareup.okhttp.Call {{operationId}}Call({{#parameters}}{{{dataType}}} {{paramName}}, {{/parameters}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object {{localVariablePrefix}}localVarPostBody = {{^isForm}}{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}{{/isForm}}{{#isForm}}null{{/isForm}}; - + // create path and map variables String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; @@ -127,7 +194,7 @@ public class {{classname}} { String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#has this 'more'}}, {{/has}}{{/authMethods}} }; return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarCollectionQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call {{operationId}}ValidateBeforeCall({{#parameters}}{{{dataType}}} {{paramName}}, {{/parameters}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { {{^performBeanValidation}} @@ -137,7 +204,7 @@ public class {{classname}} { throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)"); } {{/required}}{{/parameters}} - + com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#parameters}}{{paramName}}, {{/parameters}}progressListener, progressRequestListener); return {{localVariablePrefix}}call; @@ -155,7 +222,7 @@ public class {{classname}} { if (violations.size() == 0) { com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#parameters}}{{paramName}}, {{/parameters}}progressListener, progressRequestListener); return {{localVariablePrefix}}call; - + } else { throw new BeanValidationException((Set) violations); } @@ -166,14 +233,62 @@ public class {{classname}} { e.printStackTrace(); throw new ApiException(e.getMessage()); } - + {{/performBeanValidation}} - - - - + + + + + } + + {{#hasOptionalParams}} + /** + * {{summary}} + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}}{{#returnType}} + * @return {{returnType}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}) throws ApiException { + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); } + /** + * {{summary}} + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call.{{#returnType}} + * @return {{returnType}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}Opts({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals) throws ApiException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + {{/hasOptionalParams}} + /** * {{summary}} * {{notes}}{{#parameters}} @@ -190,6 +305,54 @@ public class {{classname}} { return {{localVariablePrefix}}resp.getData();{{/returnType}} } + {{#hasOptionalParams}} + /** + * {{summary}} + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}}{{#returnType}} + * @return {{returnType}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#requiredParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}) throws ApiException { + return {{operationId}}WithHttpInfo({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + + /** + * {{summary}} + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call.{{#returnType}} + * @return {{returnType}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}OptsWithHttpInfo({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals) throws ApiException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + return {{operationId}}WithHttpInfo({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + {{/hasOptionalParams}} + /** * {{summary}} * {{notes}}{{#parameters}} @@ -207,6 +370,56 @@ public class {{classname}} { return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}localVarReturnType);{{/returnType}}{{^returnType}}return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}} } + {{#hasOptionalParams}} + /** + * {{summary}} (asynchronously) + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}} + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public com.squareup.okhttp.Call {{operationId}}Async({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException { + return {{operationId}}Async({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}, {{/allParams}}{{localVariablePrefix}}callback); + } + + /** + * {{summary}} (asynchronously) + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{description}} (required){{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call. + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public com.squareup.okhttp.Call {{operationId}}OptsAsync({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals, final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + return {{operationId}}Async({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}, {{/allParams}}{{localVariablePrefix}}callback); + } + {{/hasOptionalParams}} + /** * {{summary}} (asynchronously) * {{notes}}{{#parameters}} @@ -248,4 +461,4 @@ public class {{classname}} { {{/contents}} {{/operation}} } -{{/operations}} \ No newline at end of file +{{/operations}} From 1de5d2b22d67768f8e07d1c2467fe0da86d2961f Mon Sep 17 00:00:00 2001 From: Michael Kourlas Date: Thu, 27 May 2021 20:43:59 -0400 Subject: [PATCH 2/3] Support new patterns for resttemplate type --- .../Java/libraries/resttemplate/api.mustache | 75 ++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache index 8350062ef1..00da747ac6 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache @@ -49,6 +49,79 @@ public class {{classname}} { {{#operation}} {{#contents}} + {{#hasOptionalParams}} + public static class {{operationIdCamelCase}}Optionals { + {{#allParams}}{{^required}} + public {{{dataType}}} {{paramName}}() { + return this.{{paramName}}; + } + + public {{operationIdCamelCase}}Optionals {{paramName}}({{{dataType}}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + private {{{dataType}}} {{paramName}} = null; + {{/required}}{{/allParams}} + } + {{/hasOptionalParams}} + + {{#hasOptionalParams}} + /** + * {{summary}} + * {{notes}} + {{#requiredParams}} + * @param {{paramName}} {{description}} (required) + {{/requiredParams}} + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}) throws RestClientException { + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + + /** + * {{summary}} + * {{notes}} + {{#requiredParams}} + * @param {{paramName}} {{description}} (required) + {{/requiredParams}} + * @param optionals An object containing the optional parameters for this API call. + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}Opts({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}{{operationIdCamelCase}}Optionals optionals) throws RestClientException { + if (optionals == null) { + optionals = new {{operationIdCamelCase}}Optionals(); + } + {{#returnType}}return {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}optionals.{{paramName}}(){{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + {{/hasOptionalParams}} + /** * {{summary}} * {{notes}} @@ -85,7 +158,7 @@ public class {{classname}} { {{/pathParams}} {{/hasPathParams}} String {{localVariablePrefix}}path = UriComponentsBuilder.fromPath("{{{path}}}"){{#hasPathParams}}.buildAndExpand(uriVariables){{/hasPathParams}}{{^hasPathParams}}.build(){{/hasPathParams}}.toUriString(); - + final MultiValueMap {{localVariablePrefix}}queryParams = new LinkedMultiValueMap(); final HttpHeaders {{localVariablePrefix}}headerParams = new HttpHeaders(); final MultiValueMap {{localVariablePrefix}}formParams = new LinkedMultiValueMap(); From 69e19afca8e75fea0e10c452607bc220d94de9c0 Mon Sep 17 00:00:00 2001 From: Michael Kourlas Date: Thu, 27 May 2021 22:35:14 -0400 Subject: [PATCH 3/3] Fix Javadoc issue --- .../handlebars/Java/libraries/resttemplate/api.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache index 00da747ac6..efe2718e1b 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache @@ -76,7 +76,7 @@ public class {{classname}} { {{#returnType}} * @return {{returnType}} {{/returnType}} - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API {{#isDeprecated}} * @deprecated {{/isDeprecated}} @@ -102,7 +102,7 @@ public class {{classname}} { {{#returnType}} * @return {{returnType}} {{/returnType}} - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API {{#isDeprecated}} * @deprecated {{/isDeprecated}}