From 5a516f0e53b7e5f42b6384ebfd89d9e867ecbe7e Mon Sep 17 00:00:00 2001 From: Luis Ballabeni Date: Mon, 4 May 2020 12:03:21 -0400 Subject: [PATCH 1/3] Fix #6157: Updated native template to fix null async return Should fix issue: https://github.com/OpenAPITools/openapi-generator/issues/6157 --- .../src/main/resources/Java/libraries/native/api.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 23388d36a76d..7a2b67d897a7 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 @@ -181,12 +181,12 @@ public class {{classname}} { ); } else { return CompletableFuture.completedFuture( - {{#returnValue}} + {{#returnType}} memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {}) - {{/returnValue}} - {{^returnValue}} + {{/returnType}} + {{^returnType}} null - {{/returnValue}} + {{/returnType}} ); } }); From aad50a2c6ec8c9681de67161a973df26a315fcfd Mon Sep 17 00:00:00 2001 From: Luis Ballabeni Date: Mon, 4 May 2020 18:15:29 -0400 Subject: [PATCH 2/3] fixed uncaught json exception in java native api gen --- .../Java/libraries/native/api.mustache | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 7a2b67d897a7..4c33eb97ad3e 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 @@ -9,6 +9,7 @@ import {{invokerPackage}}.Pair; import {{import}}; {{/imports}} +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -180,14 +181,18 @@ public class {{classname}} { localVarResponse.body()) ); } else { - return CompletableFuture.completedFuture( - {{#returnType}} - memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {}) - {{/returnType}} - {{^returnType}} - null - {{/returnType}} - ); + try { + return CompletableFuture.completedFuture( + {{#returnType}} + memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {}) + {{/returnType}} + {{^returnType}} + null + {{/returnType}} + ); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } } }); {{/asyncNative}} From 3ed64fd1e2ba235d5e731c86f23a4257c23c0cf5 Mon Sep 17 00:00:00 2001 From: Luis Ballabeni Date: Mon, 4 May 2020 18:17:14 -0400 Subject: [PATCH 3/3] cleaning up --- .../src/main/resources/Java/libraries/native/api.mustache | 1 - 1 file changed, 1 deletion(-) 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 4c33eb97ad3e..7d6ed2d4bb7a 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 @@ -9,7 +9,6 @@ import {{invokerPackage}}.Pair; import {{import}}; {{/imports}} -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper;