diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java index 81b1cc166d17..0f00ca520506 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java @@ -67,6 +67,7 @@ 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; @@ -703,7 +704,7 @@ public HttpEntity serialize(Object obj, Map formParams, ContentT 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); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java index d92b2555617f..3bce7e0f2caa 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java @@ -67,6 +67,7 @@ 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; @@ -796,7 +797,7 @@ public HttpEntity serialize(Object obj, Map formParams, ContentT 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); }