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