From 6dc9a20aac17db39dc65f06f57347f805dc839e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20de=20Chivr=C3=A9?= Date: Wed, 13 Dec 2023 12:50:29 -1000 Subject: [PATCH] fix(java): apache-httpclient serialization error fixes following related issue: https://github.com/OpenAPITools/openapi-generator/issues/12797 --- .../Java/libraries/apache-httpclient/ApiClient.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache index edb36a84774f..e3f72169a672 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache @@ -61,6 +61,7 @@ import java.io.InputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.charset.UnsupportedCharsetException; import java.nio.file.Files; import java.nio.file.StandardCopyOption; @@ -785,7 +786,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { String mimeType = contentType.getMimeType(); if (isJsonMime(mimeType)) { try { - return new StringEntity(objectMapper.writeValueAsString(obj), contentType); + return new StringEntity(objectMapper.writeValueAsString(obj), contentType.withCharset(StandardCharsets.UTF_8)); } catch (JsonProcessingException e) { throw new ApiException(e); }