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 2162321690a..b90bbb117b8 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 @@ -707,18 +707,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { /** * Parse content type object from header value */ - private ContentType getContentType(String headerValue) throws ApiException { - try { - return ContentType.parse(headerValue); - } catch (ParseException e) { - throw new ApiException("Could not parse content type " + headerValue); - } + private ContentType getContentType(String headerValue) { + return ContentType.getByMimeType(headerValue); } /** * Get content type of a response or null if one was not provided */ - private String getResponseMimeType(HttpResponse response) throws ApiException { + private String getResponseMimeType(HttpResponse response) { Header contentTypeHeader = response.getFirstHeader("Content-Type"); if (contentTypeHeader != null) { return getContentType(contentTypeHeader.getValue()).getMimeType(); 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 a6e7049085a..cc89a408f81 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 @@ -662,18 +662,14 @@ public class ApiClient extends JavaTimeFormatter { /** * Parse content type object from header value */ - private ContentType getContentType(String headerValue) throws ApiException { - try { - return ContentType.parse(headerValue); - } catch (ParseException e) { - throw new ApiException("Could not parse content type " + headerValue); - } + private ContentType getContentType(String headerValue) { + return ContentType.getByMimeType(headerValue); } /** * Get content type of a response or null if one was not provided */ - private String getResponseMimeType(HttpResponse response) throws ApiException { + private String getResponseMimeType(HttpResponse response) { Header contentTypeHeader = response.getFirstHeader("Content-Type"); if (contentTypeHeader != null) { return getContentType(contentTypeHeader.getValue()).getMimeType();