diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/ApiClient.mustache index fb80f0d2dba..3bcf3ede667 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/ApiClient.mustache @@ -18,6 +18,7 @@ import io.vertx.core.file.FileSystem; import io.vertx.core.file.OpenOptions; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; +import io.vertx.core.json.DecodeException; import io.vertx.core.json.Json; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.HttpRequest; @@ -553,7 +554,11 @@ public class ApiClient { handleFileDownload(httpResponse, handler); return; } else { - resultContent = Json.decodeValue(httpResponse.body(), returnType); + try { + resultContent = Json.mapper.readValue(httpResponse.bodyAsString(), returnType); + } catch (Exception e) { + throw new DecodeException("Failed to decode:" + e.getMessage(), e); + } } result = Future.succeededFuture(resultContent); } @@ -597,4 +602,4 @@ public class ApiClient { auth.applyToParams(queryParams, headerParams); } } -} \ No newline at end of file +} diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ApiClient.java index 49e53810020..b77033426da 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ApiClient.java @@ -18,6 +18,7 @@ import io.vertx.core.file.FileSystem; import io.vertx.core.file.OpenOptions; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; +import io.vertx.core.json.DecodeException; import io.vertx.core.json.Json; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.HttpRequest; @@ -554,7 +555,11 @@ public class ApiClient { handleFileDownload(httpResponse, handler); return; } else { - resultContent = Json.decodeValue(httpResponse.body(), returnType); + try { + resultContent = Json.mapper.readValue(httpResponse.bodyAsString(), returnType); + } catch (Exception e) { + throw new DecodeException("Failed to decode:" + e.getMessage(), e); + } } result = Future.succeededFuture(resultContent); } @@ -598,4 +603,4 @@ public class ApiClient { auth.applyToParams(queryParams, headerParams); } } -} \ No newline at end of file +}