diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 31ebbef1f9ee..0ff3321e0ae3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -229,7 +229,11 @@ public void processOpts() { if ("retrofit2".equals(getLibrary()) && !usePlayWS) { supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); } - } else if ("jersey2".equals(getLibrary()) || "resteasy".equals(getLibrary())) { + } else if ("jersey2".equals(getLibrary())) { + supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); + supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java")); + additionalProperties.put("jackson", "true"); + } else if ("resteasy".equals(getLibrary())) { supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); additionalProperties.put("jackson", "true"); } else if("jersey1".equals(getLibrary())) { diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache index e6cd79c04168..a699e001f176 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -70,9 +70,6 @@ public class ApiClient { protected Map authentications; - protected int statusCode; - protected Map> responseHeaders; - protected DateFormat dateFormat; public ApiClient() { @@ -119,22 +116,6 @@ public class ApiClient { return this; } - /** - * Gets the status code of the previous request - * @return Status code - */ - public int getStatusCode() { - return statusCode; - } - - /** - * Gets the response headers of the previous request - * @return Response headers - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - /** * Get authentications (key: authentication name, value: authentication). * @return Map of authentication object @@ -669,7 +650,7 @@ public class ApiClient { * @return The response body in type of string * @throws ApiException API exception */ - public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType) throws ApiException { + public ApiResponse invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); // Not using `.target(this.basePath).path(path)` below, @@ -724,16 +705,16 @@ public class ApiClient { throw new ApiException(500, "unknown method type " + method); } - statusCode = response.getStatusInfo().getStatusCode(); - responseHeaders = buildResponseHeaders(response); + int statusCode = response.getStatusInfo().getStatusCode(); + Map> responseHeaders = buildResponseHeaders(response); if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) { - return null; + return new ApiResponse<>(statusCode, responseHeaders); } else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) { if (returnType == null) - return null; + return new ApiResponse<>(statusCode, responseHeaders); else - return deserialize(response, returnType); + return new ApiResponse<>(statusCode, responseHeaders, deserialize(response, returnType)); } else { String message = "error"; String respBody = null; diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiResponse.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiResponse.mustache new file mode 100644 index 000000000000..2f01685a0afe --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiResponse.mustache @@ -0,0 +1,48 @@ +{{>licenseInfo}} + +package {{invokerPackage}}; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache index dd84a7dbd318..fed034609c89 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache @@ -2,6 +2,7 @@ package {{package}}; import {{invokerPackage}}.ApiException; import {{invokerPackage}}.ApiClient; +import {{invokerPackage}}.ApiResponse; import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; @@ -61,6 +62,35 @@ public class {{classname}} { @Deprecated {{/isDeprecated}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { + {{#returnType}} + return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).getData(); + {{/returnType}}{{^returnType}} + {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{/returnType}} + } + + /** + * {{summary}} + * {{notes}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/allParams}} + {{#returnType}} + * @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}> + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set @@ -105,7 +135,7 @@ public class {{classname}} { GenericType<{{{returnType}}}> {{localVariablePrefix}}localVarReturnType = new GenericType<{{{returnType}}}>() {}; return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccept, {{localVariablePrefix}}localVarContentType, {{localVariablePrefix}}localVarAuthNames, {{localVariablePrefix}}localVarReturnType); {{/returnType}}{{^returnType}} - {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccept, {{localVariablePrefix}}localVarContentType, {{localVariablePrefix}}localVarAuthNames, null); + return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccept, {{localVariablePrefix}}localVarContentType, {{localVariablePrefix}}localVarAuthNames, null); {{/returnType}} } {{/operation}} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java index b7341098733b..ba800f4230c5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java @@ -64,9 +64,6 @@ public class ApiClient { protected Map authentications; - protected int statusCode; - protected Map> responseHeaders; - protected DateFormat dateFormat; public ApiClient() { @@ -114,22 +111,6 @@ public ApiClient setBasePath(String basePath) { return this; } - /** - * Gets the status code of the previous request - * @return Status code - */ - public int getStatusCode() { - return statusCode; - } - - /** - * Gets the response headers of the previous request - * @return Response headers - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - /** * Get authentications (key: authentication name, value: authentication). * @return Map of authentication object @@ -658,7 +639,7 @@ public File prepareDownloadFile(Response response) throws IOException { * @return The response body in type of string * @throws ApiException API exception */ - public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType) throws ApiException { + public ApiResponse invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); // Not using `.target(this.basePath).path(path)` below, @@ -713,16 +694,16 @@ public T invokeAPI(String path, String method, List queryParams, Objec throw new ApiException(500, "unknown method type " + method); } - statusCode = response.getStatusInfo().getStatusCode(); - responseHeaders = buildResponseHeaders(response); + int statusCode = response.getStatusInfo().getStatusCode(); + Map> responseHeaders = buildResponseHeaders(response); if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) { - return null; + return new ApiResponse<>(statusCode, responseHeaders); } else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) { if (returnType == null) - return null; + return new ApiResponse<>(statusCode, responseHeaders); else - return deserialize(response, returnType); + return new ApiResponse<>(statusCode, responseHeaders, deserialize(response, returnType)); } else { String message = "error"; String respBody = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiResponse.java new file mode 100644 index 000000000000..389c0b199b7b --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiResponse.java @@ -0,0 +1,59 @@ +/* + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/AnotherFakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/AnotherFakeApi.java index 494f81b84d2d..a4201c9391bd 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/AnotherFakeApi.java @@ -2,6 +2,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; @@ -42,6 +43,17 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException if fails to make API call */ public Client testSpecialTags(Client body) throws ApiException { + return testSpecialTagsWithHttpInfo(body).getData(); + } + + /** + * To test special tags + * To test special tags + * @param body client model (required) + * @return ApiResponse<Client> + * @throws ApiException if fails to make API call + */ + public ApiResponse testSpecialTagsWithHttpInfo(Client body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java index 2980f8bb1fa9..293591710ea4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java @@ -2,6 +2,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; @@ -46,6 +47,17 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException if fails to make API call */ public Boolean fakeOuterBooleanSerialize(Boolean body) throws ApiException { + return fakeOuterBooleanSerializeWithHttpInfo(body).getData(); + } + + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @return ApiResponse<Boolean> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -82,6 +94,17 @@ public Boolean fakeOuterBooleanSerialize(Boolean body) throws ApiException { * @throws ApiException if fails to make API call */ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws ApiException { + return fakeOuterCompositeSerializeWithHttpInfo(body).getData(); + } + + /** + * + * Test serialization of object with outer number type + * @param body Input composite as post body (optional) + * @return ApiResponse<OuterComposite> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -118,6 +141,17 @@ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Ap * @throws ApiException if fails to make API call */ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws ApiException { + return fakeOuterNumberSerializeWithHttpInfo(body).getData(); + } + + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @return ApiResponse<BigDecimal> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -154,6 +188,17 @@ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws ApiException * @throws ApiException if fails to make API call */ public String fakeOuterStringSerialize(String body) throws ApiException { + return fakeOuterStringSerializeWithHttpInfo(body).getData(); + } + + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse fakeOuterStringSerializeWithHttpInfo(String body) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -190,6 +235,17 @@ public String fakeOuterStringSerialize(String body) throws ApiException { * @throws ApiException if fails to make API call */ public Client testClientModel(Client body) throws ApiException { + return testClientModelWithHttpInfo(body).getData(); + } + + /** + * To test \"client\" model + * To test \"client\" model + * @param body client model (required) + * @return ApiResponse<Client> + * @throws ApiException if fails to make API call + */ + public ApiResponse testClientModelWithHttpInfo(Client body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set @@ -243,6 +299,30 @@ public Client testClientModel(Client body) throws ApiException { * @throws ApiException if fails to make API call */ public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException { + + testEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @throws ApiException if fails to make API call + */ + public ApiResponse testEndpointParametersWithHttpInfo(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'number' is set @@ -317,7 +397,7 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat String[] localVarAuthNames = new String[] { "http_basic_test" }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * To test enum parameters @@ -333,6 +413,24 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat * @throws ApiException if fails to make API call */ public void testEnumParameters(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) throws ApiException { + + testEnumParametersWithHttpInfo(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); + } + + /** + * To test enum parameters + * To test enum parameters + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @throws ApiException if fails to make API call + */ + public ApiResponse testEnumParametersWithHttpInfo(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) throws ApiException { Object localVarPostBody = null; // create path and map variables @@ -372,7 +470,7 @@ public void testEnumParameters(List enumFormStringArray, String enumForm String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * test inline additionalProperties @@ -381,6 +479,17 @@ public void testEnumParameters(List enumFormStringArray, String enumForm * @throws ApiException if fails to make API call */ public void testInlineAdditionalProperties(Object param) throws ApiException { + + testInlineAdditionalPropertiesWithHttpInfo(param); + } + + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Object param) throws ApiException { Object localVarPostBody = param; // verify the required parameter 'param' is set @@ -412,7 +521,7 @@ public void testInlineAdditionalProperties(Object param) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * test json serialization of form data @@ -422,6 +531,18 @@ public void testInlineAdditionalProperties(Object param) throws ApiException { * @throws ApiException if fails to make API call */ public void testJsonFormData(String param, String param2) throws ApiException { + + testJsonFormDataWithHttpInfo(param, param2); + } + + /** + * test json serialization of form data + * + * @param param field1 (required) + * @param param2 field2 (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse testJsonFormDataWithHttpInfo(String param, String param2) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'param' is set @@ -462,6 +583,6 @@ public void testJsonFormData(String param, String param2) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java index 41b78ca6524c..c27bda18a6a5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -2,6 +2,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; @@ -42,6 +43,17 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException if fails to make API call */ public Client testClassname(Client body) throws ApiException { + return testClassnameWithHttpInfo(body).getData(); + } + + /** + * To test class name in snake case + * + * @param body client model (required) + * @return ApiResponse<Client> + * @throws ApiException if fails to make API call + */ + public ApiResponse testClassnameWithHttpInfo(Client body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index 6af9763779c5..e2cca5b3eecc 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -2,6 +2,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; @@ -43,6 +44,17 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException if fails to make API call */ public void addPet(Pet body) throws ApiException { + + addPetWithHttpInfo(body); + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse addPetWithHttpInfo(Pet body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set @@ -74,7 +86,7 @@ public void addPet(Pet body) throws ApiException { String[] localVarAuthNames = new String[] { "petstore_auth" }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Deletes a pet @@ -84,6 +96,18 @@ public void addPet(Pet body) throws ApiException { * @throws ApiException if fails to make API call */ public void deletePet(Long petId, String apiKey) throws ApiException { + + deletePetWithHttpInfo(petId, apiKey); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @throws ApiException if fails to make API call + */ + public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -118,7 +142,7 @@ public void deletePet(Long petId, String apiKey) throws ApiException { String[] localVarAuthNames = new String[] { "petstore_auth" }; - apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Finds Pets by status @@ -128,6 +152,17 @@ public void deletePet(Long petId, String apiKey) throws ApiException { * @throws ApiException if fails to make API call */ public List findPetsByStatus(List status) throws ApiException { + return findPetsByStatusWithHttpInfo(status).getData(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'status' is set @@ -172,6 +207,19 @@ public List findPetsByStatus(List status) throws ApiException { */ @Deprecated public List findPetsByTags(List tags) throws ApiException { + return findPetsByTagsWithHttpInfo(tags).getData(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return ApiResponse<List<Pet>> + * @throws ApiException if fails to make API call + * @deprecated + */ + @Deprecated + public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'tags' is set @@ -214,6 +262,17 @@ public List findPetsByTags(List tags) throws ApiException { * @throws ApiException if fails to make API call */ public Pet getPetById(Long petId) throws ApiException { + return getPetByIdWithHttpInfo(petId).getData(); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return ApiResponse<Pet> + * @throws ApiException if fails to make API call + */ + public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -255,6 +314,17 @@ public Pet getPetById(Long petId) throws ApiException { * @throws ApiException if fails to make API call */ public void updatePet(Pet body) throws ApiException { + + updatePetWithHttpInfo(body); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithHttpInfo(Pet body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set @@ -286,7 +356,7 @@ public void updatePet(Pet body) throws ApiException { String[] localVarAuthNames = new String[] { "petstore_auth" }; - apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Updates a pet in the store with form data @@ -297,6 +367,19 @@ public void updatePet(Pet body) throws ApiException { * @throws ApiException if fails to make API call */ public void updatePetWithForm(Long petId, String name, String status) throws ApiException { + + updatePetWithFormWithHttpInfo(petId, name, status); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @throws ApiException if fails to make API call + */ + public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -333,7 +416,7 @@ public void updatePetWithForm(Long petId, String name, String status) throws Api String[] localVarAuthNames = new String[] { "petstore_auth" }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * uploads an image @@ -345,6 +428,19 @@ public void updatePetWithForm(Long petId, String name, String status) throws Api * @throws ApiException if fails to make API call */ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + return uploadFileWithHttpInfo(petId, additionalMetadata, file).getData(); + } + + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) + * @return ApiResponse<ModelApiResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 22be0ebb0274..ede729d95404 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -2,6 +2,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; @@ -41,6 +42,17 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException if fails to make API call */ public void deleteOrder(String orderId) throws ApiException { + + deleteOrderWithHttpInfo(orderId); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -73,7 +85,7 @@ public void deleteOrder(String orderId) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Returns pet inventories by status @@ -82,6 +94,16 @@ public void deleteOrder(String orderId) throws ApiException { * @throws ApiException if fails to make API call */ public Map getInventory() throws ApiException { + return getInventoryWithHttpInfo().getData(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return ApiResponse<Map<String, Integer>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { Object localVarPostBody = null; // create path and map variables @@ -118,6 +140,17 @@ public Map getInventory() throws ApiException { * @throws ApiException if fails to make API call */ public Order getOrderById(Long orderId) throws ApiException { + return getOrderByIdWithHttpInfo(orderId).getData(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -160,6 +193,17 @@ public Order getOrderById(Long orderId) throws ApiException { * @throws ApiException if fails to make API call */ public Order placeOrder(Order body) throws ApiException { + return placeOrderWithHttpInfo(body).getData(); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return ApiResponse<Order> + * @throws ApiException if fails to make API call + */ + public ApiResponse placeOrderWithHttpInfo(Order body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index a7dced63d855..034fab71b590 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -2,6 +2,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; @@ -41,6 +42,17 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException if fails to make API call */ public void createUser(User body) throws ApiException { + + createUserWithHttpInfo(body); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse createUserWithHttpInfo(User body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set @@ -72,7 +84,7 @@ public void createUser(User body) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Creates list of users with given input array @@ -81,6 +93,17 @@ public void createUser(User body) throws ApiException { * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(List body) throws ApiException { + + createUsersWithArrayInputWithHttpInfo(body); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(List body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set @@ -112,7 +135,7 @@ public void createUsersWithArrayInput(List body) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Creates list of users with given input array @@ -121,6 +144,17 @@ public void createUsersWithArrayInput(List body) throws ApiException { * @throws ApiException if fails to make API call */ public void createUsersWithListInput(List body) throws ApiException { + + createUsersWithListInputWithHttpInfo(body); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse createUsersWithListInputWithHttpInfo(List body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set @@ -152,7 +186,7 @@ public void createUsersWithListInput(List body) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Delete user @@ -161,6 +195,17 @@ public void createUsersWithListInput(List body) throws ApiException { * @throws ApiException if fails to make API call */ public void deleteUser(String username) throws ApiException { + + deleteUserWithHttpInfo(username); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'username' is set @@ -193,7 +238,7 @@ public void deleteUser(String username) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Get user by user name @@ -203,6 +248,17 @@ public void deleteUser(String username) throws ApiException { * @throws ApiException if fails to make API call */ public User getUserByName(String username) throws ApiException { + return getUserByNameWithHttpInfo(username).getData(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return ApiResponse<User> + * @throws ApiException if fails to make API call + */ + public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'username' is set @@ -246,6 +302,18 @@ public User getUserByName(String username) throws ApiException { * @throws ApiException if fails to make API call */ public String loginUser(String username, String password) throws ApiException { + return loginUserWithHttpInfo(username, password).getData(); + } + + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'username' is set @@ -292,6 +360,16 @@ public String loginUser(String username, String password) throws ApiException { * @throws ApiException if fails to make API call */ public void logoutUser() throws ApiException { + + logoutUserWithHttpInfo(); + } + + /** + * Logs out current logged in user session + * + * @throws ApiException if fails to make API call + */ + public ApiResponse logoutUserWithHttpInfo() throws ApiException { Object localVarPostBody = null; // create path and map variables @@ -318,7 +396,7 @@ public void logoutUser() throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } /** * Updated user @@ -328,6 +406,18 @@ public void logoutUser() throws ApiException { * @throws ApiException if fails to make API call */ public void updateUser(String username, User body) throws ApiException { + + updateUserWithHttpInfo(username, body); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param body Updated user object (required) + * @throws ApiException if fails to make API call + */ + public ApiResponse updateUserWithHttpInfo(String username, User body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'username' is set @@ -365,6 +455,6 @@ public void updateUser(String username, User body) throws ApiException { String[] localVarAuthNames = new String[] { }; - apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } }