diff --git a/README.md b/README.md index 08d16048effc..b50afb523659 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Stable releases in Maven Central](https://img.shields.io/maven-metadata/v/https/repo1.maven.org/maven2/org/openapitools/openapi-generator/maven-metadata.xml.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22) [![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-orange)](./LICENSE) [![Open Collective backers](https://img.shields.io/opencollective/backers/openapi_generator?color=orange&label=OpenCollective%20Backers)](https://opencollective.com/openapi_generator) -[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ) +[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA) [![Follow OpenAPI Generator Twitter account to get the latest update](https://img.shields.io/twitter/follow/oas_generator.svg?style=social&label=Follow)](https://twitter.com/oas_generator) [![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/OpenAPITools/openapi-generator) [![Conan Center](https://shields.io/conan/v/openapi-generator)](https://conan.io/center/recipes/openapi-generator) diff --git a/docs/faq.md b/docs/faq.md index 9b416e374d56..061135a68b53 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -5,7 +5,7 @@ title: "FAQ: General" ## Do you have a chat room? -[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ) +[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA) ## What is the governance structure of the OpenAPI Generator project? diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache index 0ade8e9c2bae..309ee2fc3214 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache @@ -271,22 +271,46 @@ public class {{classname}} { } {{/vendorExtensions.x-java-text-plain-string}} {{^vendorExtensions.x-java-text-plain-string}} - return new ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - {{#returnType}} - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {}) // closes the InputStream - {{/returnType}} - {{^returnType}} - null - {{/returnType}} + {{#returnType}} + {{! Fix for https://github.com/OpenAPITools/openapi-generator/issues/13968 }} + {{! This part had a bugfix for an empty response in the past, but this part of that PR was reverted because it was not doing anything. }} + {{! Keep this documentation here, because the problem is not obvious. }} + {{! `InputStream.available()` was used, but that only works for inputstreams that are already in memory, it will not give the right result if it is a remote stream. We only work with remote streams here. }} + {{! https://github.com/OpenAPITools/openapi-generator/pull/13993/commits/3e!37411d2acef0311c82e6d941a8e40b3bc0b6da }} + {{! The `available` method would work with a `PushbackInputStream`, because we could read 1 byte to check if it exists then push it back so Jackson can read it again. The issue with that is that it will also insert an ascii character for "head of input" and that will break Jackson as it does not handle special whitespace characters. }} + {{! A fix for that problem is to read it into a string and remove those characters, but if we need to read it before giving it to jackson to fix the string then just reading it into a string as is to do an emptiness check is the cleaner solution. }} + {{! We could also manipulate the inputstream to remove that bad character, but string manipulation is easier to read and this codepath is not asyncronus so we do not gain anything by reading the stream later. }} + {{! This fix does make it unsuitable for large amounts of data because `InputStream.readAllbytes` is not meant for it, but a syncronus client is already not the right tool for that.}} + if (localVarResponse.body() == null) { + return new ApiResponse<{{{returnType}}}>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse<{{{returnType}}}>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {}) ); + {{/returnType}} + {{^returnType}} + return new ApiResponse<{{{returnType}}}>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + {{/returnType}} {{/vendorExtensions.x-java-text-plain-string}} } finally { {{^returnType}} // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); {{/returnType}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index dc31a2f42a1c..f050ffe78776 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -3263,4 +3263,73 @@ public void testGenerateParameterId() { " getCall(Integer queryParameter, final ApiCallback _callback)" ); } + + @Test + public void callNativeServiceWithEmptyResponseSync() throws IOException { + Map properties = new HashMap<>(); + properties.put(CodegenConstants.API_PACKAGE, "xyz.abcdef.api"); + properties.put("asyncNative", "false"); + + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("java") + .setLibrary(JavaClientCodegen.NATIVE) + .setAdditionalProperties(properties) + .setInputSpec("src/test/resources/3_0/java/native/issue13968.yaml") + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + + Map files = generator.opts(clientOptInput).generate().stream() + .collect(Collectors.toMap(File::getName, Function.identity())); + + File apiFile = files.get("DefaultApi.java"); + assertNotNull(apiFile); + + JavaFileAssert.assertThat(apiFile).fileContains( + //reading the body into a string, then checking if it is blank. + "String responseBody = new String(localVarResponse.body().readAllBytes());", + "responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {})" + ); + } + + + /** + * This checks that the async client is not affected by this fix. + * See https://github.com/OpenAPITools/openapi-generator/issues/13968 + */ + @Test + public void callNativeServiceWithEmptyResponseAsync() throws IOException { + Map properties = new HashMap<>(); + properties.put(CodegenConstants.API_PACKAGE, "xyz.abcdef.api"); + properties.put("asyncNative", "true"); + + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("java") + .setLibrary(JavaClientCodegen.NATIVE) + .setAdditionalProperties(properties) + .setInputSpec("src/test/resources/3_0/java/native/issue13968.yaml") + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + + Map files = generator.opts(clientOptInput).generate().stream() + .collect(Collectors.toMap(File::getName, Function.identity())); + + File apiFile = files.get("DefaultApi.java"); + assertNotNull(apiFile); + + JavaFileAssert.assertThat(apiFile).fileDoesNotContain( + //reading the body into a string, then checking if it is blank. + "String responseBody = new String(localVarResponse.body().readAllBytes());", + "responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {})" + ); + } } \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/java/native/issue13968.yaml b/modules/openapi-generator/src/test/resources/3_0/java/native/issue13968.yaml new file mode 100644 index 000000000000..e44e500d5d29 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/java/native/issue13968.yaml @@ -0,0 +1,33 @@ +openapi: 3.0.3 +info: + title: Example Hello API + description: '' + version: v1 +servers: + - url: http://localhost + description: Global Endpoint +paths: + /v1/emptyResponse: + get: + operationId: empty + description: returns an empty response + responses: + 200: + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/LocationData' + 204: + description: Empty response +components: + schemas: + LocationData: + type: object + properties: + xPos: + type: integer + format: int32 + yPos: + type: integer + format: int32 diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java index 257a7a545066..850a0067f4b0 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java @@ -120,10 +120,21 @@ public ApiResponse testBinaryGifWithHttpInfo() throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testBinaryGif", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -494,10 +505,21 @@ public ApiResponse testEchoBodyAllOfPetWithHttpInfo(Pet pet) throws ApiExce if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testEchoBodyAllOfPet", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -650,10 +672,21 @@ public ApiResponse testEchoBodyPetWithHttpInfo(Pet pet) throws ApiException if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testEchoBodyPet", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -806,10 +839,21 @@ public ApiResponse testEchoBodyStringEnumWithHttpInfo(String body if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testEchoBodyStringEnum", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java index 8a29cf444b0a..d8e77055b861 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java @@ -121,10 +121,21 @@ public ApiResponse addPetWithHttpInfo(Pet pet) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("addPet", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -199,15 +210,15 @@ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("deletePet", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -280,10 +291,21 @@ public ApiResponse> findPetsByStatusWithHttpInfo(List status) if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("findPetsByStatus", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -371,10 +393,21 @@ public ApiResponse> findPetsByTagsWithHttpInfo(List tags) thro if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("findPetsByTags", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -458,10 +491,21 @@ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getPetById", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -535,10 +579,21 @@ public ApiResponse updatePetWithHttpInfo(Pet pet) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("updatePet", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -615,15 +670,15 @@ public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("updatePetWithForm", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -714,10 +769,21 @@ public ApiResponse uploadFileWithHttpInfo(Long petId, String a if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("uploadFile", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java index 40fd9c15c9e1..69dda1a1214f 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java @@ -117,15 +117,15 @@ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiExcep if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("deleteOrder", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -193,10 +193,21 @@ public ApiResponse> getInventoryWithHttpInfo() throws ApiEx if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getInventory", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -261,10 +272,21 @@ public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiExcep if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getOrderById", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -334,10 +356,21 @@ public ApiResponse placeOrderWithHttpInfo(Order order) throws ApiExceptio if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("placeOrder", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java index da390054dcdc..e8030ff7aa47 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java @@ -118,15 +118,15 @@ public ApiResponse createUserWithHttpInfo(User user) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("createUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -199,15 +199,15 @@ public ApiResponse createUsersWithArrayInputWithHttpInfo(List user) if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("createUsersWithArrayInput", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -280,15 +280,15 @@ public ApiResponse createUsersWithListInputWithHttpInfo(List user) t if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("createUsersWithListInput", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -361,15 +361,15 @@ public ApiResponse deleteUserWithHttpInfo(String username) throws ApiExcep if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("deleteUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -439,10 +439,21 @@ public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiEx if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getUserByName", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -514,10 +525,21 @@ public ApiResponse loginUserWithHttpInfo(String username, String passwor if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("loginUser", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -603,15 +625,15 @@ public ApiResponse logoutUserWithHttpInfo() throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("logoutUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -676,15 +698,15 @@ public ApiResponse updateUserWithHttpInfo(String username, User user) thro if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("updateUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index b1b630cd5105..f8e8956e4ea1 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -113,10 +113,21 @@ public ApiResponse call123testSpecialTagsWithHttpInfo(Client client) thr if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("call123testSpecialTags", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java index e89ac1df463d..963417360677 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -111,10 +111,21 @@ public ApiResponse fooGetWithHttpInfo() throws ApiExcepti if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fooGet", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java index a4986f04291d..0de6a99e3189 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java @@ -128,10 +128,21 @@ public ApiResponse fakeBigDecimalMapWithHttpInfo() if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fakeBigDecimalMap", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -194,10 +205,21 @@ public ApiResponse fakeHealthGetWithHttpInfo() throws ApiExce if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fakeHealthGet", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -262,10 +284,21 @@ public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body) if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fakeOuterBooleanSerialize", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -336,10 +369,21 @@ public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(Outer if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fakeOuterCompositeSerialize", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -410,10 +454,21 @@ public ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal b if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fakeOuterNumberSerialize", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -484,10 +539,21 @@ public ApiResponse fakeOuterStringSerializeWithHttpInfo(String body) thr if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("fakeOuterStringSerialize", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -551,10 +617,21 @@ public ApiResponse> getApplicationJsonUtf8WithHttpInfo() throws if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getApplicationJsonUtf8", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -617,10 +694,21 @@ public ApiResponse> getArrayOfEnumsWithHttpInfo() throws ApiExce if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getArrayOfEnums", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -683,15 +771,15 @@ public ApiResponse testAdditionalPropertiesReferenceWithHttpInfo(Map( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -764,15 +852,15 @@ public ApiResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testBodyWithFileSchema", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -847,15 +935,15 @@ public ApiResponse testBodyWithQueryParamsWithHttpInfo(String query, User if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testBodyWithQueryParams", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -949,10 +1037,21 @@ public ApiResponse testClientModelWithHttpInfo(Client client) throws Api if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testClientModel", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -1051,15 +1150,15 @@ public ApiResponse testEndpointParametersWithHttpInfo(BigDecimal number, D if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testEndpointParameters", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1205,15 +1304,15 @@ public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderS if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testEnumParameters", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1365,15 +1464,15 @@ public ApiResponse testGroupParametersWithHttpInfo(Integer requiredStringG if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testGroupParameters", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1552,15 +1651,15 @@ public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Map( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1633,15 +1732,15 @@ public ApiResponse testInlineFreeformAdditionalPropertiesWithHttpInfo(Test if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testInlineFreeformAdditionalProperties", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1716,15 +1815,15 @@ public ApiResponse testJsonFormDataWithHttpInfo(String param, String param if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testJsonFormData", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1820,15 +1919,15 @@ public ApiResponse testQueryParameterCollectionFormatWithHttpInfo(List( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -1934,15 +2033,15 @@ public ApiResponse testStringMapReferenceWithHttpInfo(Map if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testStringMapReference", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 027d90cdd940..43f1a867c6d0 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -119,10 +119,21 @@ public ApiResponse testClassnameWithHttpInfo(Client client) throws ApiEx if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("testClassname", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java index 63bb5d85db82..24c7123889d9 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java @@ -119,15 +119,15 @@ public ApiResponse addPetWithHttpInfo(Pet pet) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("addPet", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -202,15 +202,15 @@ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("deletePet", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -283,10 +283,21 @@ public ApiResponse> findPetsByStatusWithHttpInfo(List status) if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("findPetsByStatus", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -374,10 +385,21 @@ public ApiResponse> findPetsByTagsWithHttpInfo(List tags) thro if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("findPetsByTags", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -461,10 +483,21 @@ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getPetById", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -532,15 +565,15 @@ public ApiResponse updatePetWithHttpInfo(Pet pet) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("updatePet", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -617,15 +650,15 @@ public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("updatePetWithForm", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -716,10 +749,21 @@ public ApiResponse uploadFileWithHttpInfo(Long petId, String a if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("uploadFile", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -827,10 +871,21 @@ public ApiResponse uploadFileWithRequiredFileWithHttpInfo(Long if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("uploadFileWithRequiredFile", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java index 4f97d8761d30..3300e0a41d8f 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java @@ -117,15 +117,15 @@ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiExcep if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("deleteOrder", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -193,10 +193,21 @@ public ApiResponse> getInventoryWithHttpInfo() throws ApiEx if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getInventory", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse>( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) ); } finally { } @@ -261,10 +272,21 @@ public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiExcep if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getOrderById", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -334,10 +356,21 @@ public ApiResponse placeOrderWithHttpInfo(Order order) throws ApiExceptio if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("placeOrder", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java index 239f2753a8ea..9422119d52ee 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java @@ -118,15 +118,15 @@ public ApiResponse createUserWithHttpInfo(User user) throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("createUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -199,15 +199,15 @@ public ApiResponse createUsersWithArrayInputWithHttpInfo(List user) if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("createUsersWithArrayInput", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -280,15 +280,15 @@ public ApiResponse createUsersWithListInputWithHttpInfo(List user) t if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("createUsersWithListInput", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -361,15 +361,15 @@ public ApiResponse deleteUserWithHttpInfo(String username) throws ApiExcep if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("deleteUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -439,10 +439,21 @@ public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiEx if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("getUserByName", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -514,10 +525,21 @@ public ApiResponse loginUserWithHttpInfo(String username, String passwor if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("loginUser", localVarResponse); } + if (localVarResponse.body() == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}) ); } finally { } @@ -603,15 +625,15 @@ public ApiResponse logoutUserWithHttpInfo() throws ApiException { if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("logoutUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } @@ -676,15 +698,15 @@ public ApiResponse updateUserWithHttpInfo(String username, User user) thro if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("updateUser", localVarResponse); } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - null + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null ); } finally { // Drain the InputStream while (localVarResponse.body().read() != -1) { - // Ignore + // Ignore } localVarResponse.body().close(); } diff --git a/website/src/pages/index.js b/website/src/pages/index.js index 630820806ae8..d29b80c2813b 100755 --- a/website/src/pages/index.js +++ b/website/src/pages/index.js @@ -120,7 +120,7 @@ const callouts = [

Slack is free to download, and our workspace is free to sign up.