From be9a9a3837fc69de7058d95db43850a46d3e9324 Mon Sep 17 00:00:00 2001 From: Mykola Yashchenko Date: Mon, 31 Jul 2017 14:03:25 +0300 Subject: [PATCH] [Java] Jersey, Jersey2 and Resteasy clients do not support HTTP-HEAD (#6210) --- .../src/main/resources/Java/ApiClient.mustache | 5 +++-- .../main/resources/Java/libraries/jersey2/ApiClient.mustache | 4 +++- .../resources/Java/libraries/resteasy/ApiClient.mustache | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index d1336db1da4..718a7e57129 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -667,8 +667,9 @@ public class ApiClient { response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType, formParams)); } else if ("PATCH".equals(method)) { response = builder.type(contentType).header("X-HTTP-Method-Override", "PATCH").post(ClientResponse.class, serialize(body, contentType, formParams)); - } - else { + } else if ("HEAD".equals(method)) { + response = builder.head(); + } else { throw new ApiException(500, "unknown method type " + method); } return response; diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache index 6dafe4a4987..4175739c37a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -636,7 +636,7 @@ public class ApiClient { * * @param Type * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE" * @param queryParams The query parameters * @param body The request body object * @param headerParams The header parameters @@ -697,6 +697,8 @@ public class ApiClient { response = invocationBuilder.delete(); } else if ("PATCH".equals(method)) { response = invocationBuilder.method("PATCH", entity); + } else if ("HEAD".equals(method)) { + response = invocationBuilder.head(); } else { throw new ApiException(500, "unknown method type " + method); } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/ApiClient.mustache index b41f31903b9..24953959b98 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/ApiClient.mustache @@ -561,7 +561,7 @@ public class ApiClient { * Invoke API by sending HTTP request with the given options. * * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE" * @param queryParams The query parameters * @param body The request body object * @param headerParams The header parameters @@ -619,6 +619,8 @@ public class ApiClient { response = invocationBuilder.delete(); } else if ("PATCH".equals(method)) { response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity); + } else if ("HEAD".equals(method)) { + response = invocationBuilder.head(); } else { throw new ApiException(500, "unknown method type " + method); }