github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/java/libraries/jersey2/api.mustache (about) 1 package {{package}}; 2 3 import {{invokerPackage}}.ApiException; 4 import {{invokerPackage}}.ApiClient; 5 import {{invokerPackage}}.ApiResponse; 6 import {{invokerPackage}}.Configuration; 7 import {{invokerPackage}}.Pair; 8 9 import javax.ws.rs.core.GenericType; 10 11 {{#imports}}import {{import}}; 12 {{/imports}} 13 14 {{^fullJavaUtil}} 15 import java.util.ArrayList; 16 import java.util.HashMap; 17 import java.util.List; 18 import java.util.Map; 19 {{/fullJavaUtil}} 20 21 {{>generatedAnnotation}} 22 {{#operations}} 23 public class {{classname}} { 24 private ApiClient apiClient; 25 26 public {{classname}}() { 27 this(Configuration.getDefaultApiClient()); 28 } 29 30 public {{classname}}(ApiClient apiClient) { 31 this.apiClient = apiClient; 32 } 33 34 public ApiClient getApiClient() { 35 return apiClient; 36 } 37 38 public void setApiClient(ApiClient apiClient) { 39 this.apiClient = apiClient; 40 } 41 {{#operation}} 42 {{^vendorExtensions.x-group-parameters}} 43 /** 44 * {{summary}} 45 * {{notes}} 46 {{#allParams}} 47 * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} 48 {{/allParams}} 49 {{#returnType}} 50 * @return {{returnType}} 51 {{/returnType}} 52 * @throws ApiException if fails to make API call 53 {{#responses.0}} 54 * @http.response.details 55 <table summary="Response Details" border="1"> 56 <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> 57 {{#responses}} 58 <tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr> 59 {{/responses}} 60 </table> 61 {{/responses.0}} 62 {{#isDeprecated}} 63 * @deprecated 64 {{/isDeprecated}} 65 {{#externalDocs}} 66 * {{description}} 67 * @see <a href="{{url}}">{{summary}} Documentation</a> 68 {{/externalDocs}} 69 */ 70 {{#isDeprecated}} 71 @Deprecated 72 {{/isDeprecated}} 73 public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { 74 {{#returnType}}return {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}.getData(){{/returnType}}; 75 } 76 {{/vendorExtensions.x-group-parameters}} 77 78 {{^vendorExtensions.x-group-parameters}} 79 /** 80 * {{summary}} 81 * {{notes}} 82 {{#allParams}} 83 * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} 84 {{/allParams}} 85 * @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}> 86 * @throws ApiException if fails to make API call 87 {{#responses.0}} 88 * @http.response.details 89 <table summary="Response Details" border="1"> 90 <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> 91 {{#responses}} 92 <tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr> 93 {{/responses}} 94 </table> 95 {{/responses.0}} 96 {{#isDeprecated}} 97 * @deprecated 98 {{/isDeprecated}} 99 {{#externalDocs}} 100 * {{description}} 101 * @see <a href="{{url}}">{{summary}} Documentation</a> 102 {{/externalDocs}} 103 */ 104 {{#isDeprecated}} 105 @Deprecated 106 {{/isDeprecated}} 107 public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { 108 Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; 109 {{#allParams}}{{#required}} 110 // verify the required parameter '{{paramName}}' is set 111 if ({{paramName}} == null) { 112 throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{operationId}}"); 113 } 114 {{/required}}{{/allParams}} 115 // create path and map variables 116 String localVarPath = "{{{path}}}"{{#pathParams}} 117 .replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; 118 119 // query params 120 {{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>(); 121 {{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>(); 122 {{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>(); 123 {{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>(); 124 125 {{#queryParams}} 126 localVarQueryParams.addAll(apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); 127 {{/queryParams}} 128 129 {{#headerParams}}if ({{paramName}} != null) 130 localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); 131 {{/headerParams}} 132 133 {{#cookieParams}}if ({{paramName}} != null) 134 localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); 135 {{/cookieParams}} 136 137 {{#formParams}}if ({{paramName}} != null) 138 localVarFormParams.put("{{baseName}}", {{paramName}}); 139 {{/formParams}} 140 141 final String[] localVarAccepts = { 142 {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} 143 }; 144 final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); 145 146 final String[] localVarContentTypes = { 147 {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} 148 }; 149 final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); 150 151 String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} }; 152 153 {{#returnType}}GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {};{{/returnType}} 154 return apiClient.invokeAPI("{{classname}}.{{operationId}}", localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, {{#returnType}}localVarReturnType{{/returnType}}{{^returnType}}null{{/returnType}}); 155 } 156 {{#vendorExtensions.x-group-parameters}} 157 158 public class API{{operationId}}Request { 159 {{#allParams}} 160 private {{#isRequired}}final {{/isRequired}}{{{dataType}}} {{localVariablePrefix}}{{paramName}}; 161 {{/allParams}} 162 163 private API{{operationId}}Request({{#pathParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/pathParams}}) { 164 {{#pathParams}} 165 this.{{localVariablePrefix}}{{paramName}} = {{paramName}}; 166 {{/pathParams}} 167 } 168 {{#allParams}}{{^isPathParam}} 169 170 /** 171 * Set {{paramName}} 172 * @param {{paramName}} {{description}} ({{^required}}optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}{{/required}}{{#required}}required{{/required}}) 173 * @return API{{operationId}}Request 174 */ 175 public API{{operationId}}Request {{paramName}}({{{dataType}}} {{paramName}}) { 176 this.{{localVariablePrefix}}{{paramName}} = {{paramName}}; 177 return this; 178 } 179 {{/isPathParam}}{{/allParams}} 180 181 /** 182 * Execute {{operationId}} request 183 {{#returnType}}* @return {{.}}{{/returnType}} 184 * @throws ApiException if fails to make API call 185 {{#responses.0}} 186 * @http.response.details 187 <table summary="Response Details" border="1"> 188 <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> 189 {{#responses}} 190 <tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr> 191 {{/responses}} 192 </table> 193 {{/responses.0}} 194 {{#isDeprecated}}* @deprecated{{/isDeprecated}} 195 */ 196 {{#isDeprecated}}@Deprecated{{/isDeprecated}} 197 public {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}} execute() throws ApiException { 198 {{#returnType}}return {{/returnType}}this.executeWithHttpInfo().getData(); 199 } 200 201 /** 202 * Execute {{operationId}} request with HTTP info returned 203 * @return ApiResponse<{{#returnType}}{{.}}{{/returnType}}{{^returnType}}Void{{/returnType}}> 204 * @throws ApiException if fails to make API call 205 {{#responses.0}} 206 * @http.response.details 207 <table summary="Response Details" border="1"> 208 <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> 209 {{#responses}} 210 <tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr> 211 {{/responses}} 212 </table> 213 {{/responses.0}} 214 {{#isDeprecated}}* @deprecated{{/isDeprecated}} 215 */ 216 {{#isDeprecated}}@Deprecated{{/isDeprecated}} 217 public ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> executeWithHttpInfo() throws ApiException { 218 return {{operationId}}WithHttpInfo({{#allParams}}{{localVariablePrefix}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); 219 } 220 } 221 222 /** 223 * {{summary}} 224 * {{notes}}{{#pathParams}} 225 * @param {{paramName}} {{description}} (required){{/pathParams}} 226 * @return {{operationId}}Request 227 * @throws ApiException if fails to make API call 228 {{#isDeprecated}}* @deprecated{{/isDeprecated}} 229 {{#externalDocs}}* {{description}} 230 * @see <a href="{{url}}">{{summary}} Documentation</a>{{/externalDocs}} 231 */ 232 {{#isDeprecated}}@Deprecated{{/isDeprecated}} 233 public API{{operationId}}Request {{operationId}}({{#pathParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/pathParams}}) throws ApiException { 234 return new API{{operationId}}Request({{#pathParams}}{{paramName}}{{^-last}}, {{/-last}}{{/pathParams}}); 235 } 236 {{/vendorExtensions.x-group-parameters}} 237 {{/operation}} 238 } 239 {{/operations}}