From 2e1ed1cfc972f1544b84e83d44f9790036655d07 Mon Sep 17 00:00:00 2001 From: artnan Date: Fri, 28 Nov 2025 11:32:42 +0700 Subject: [PATCH 1/3] fix(java): add header parameter handling for google-api-client Header parameters defined in OpenAPI specs were being accepted as method parameters but never actually added to the HTTP request. Fixes #22457 --- .../libraries/google-api-client/api.mustache | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache index 757ee73e9261..e6fd1e44f38d 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache @@ -123,7 +123,13 @@ public class {{classname}} { GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}}; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content); + {{#headerParams}} + if ({{paramName}} != null) { + httpRequest.getHeaders().set("{{baseName}}", {{paramName}}); + } + {{/headerParams}} + return httpRequest.execute(); }{{#bodyParam}} {{#isDeprecated}} @@ -159,7 +165,13 @@ public class {{classname}} { HttpContent content = {{#bodyParam}}{{paramName}} == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, {{paramName}}){{/bodyParam}}; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content); + {{#headerParams}} + if ({{paramName}} != null) { + httpRequest.getHeaders().set("{{baseName}}", {{paramName}}); + } + {{/headerParams}} + return httpRequest.execute(); }{{/bodyParam}} {{#isDeprecated}} @@ -201,7 +213,19 @@ public class {{classname}} { GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}}; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + {{#headerParams}} + if ("{{baseName}}".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + {{/headerParams}} + } + return httpRequest.execute(); } From d424b946b8e4b9ca1f465104e0a2e9b37fff93cd Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 1 Dec 2025 12:35:05 +0800 Subject: [PATCH 2/3] update samples --- .../client/api/AnotherFakeApi.java | 24 +- .../org/openapitools/client/api/FakeApi.java | 219 +++++++++++++++--- .../client/api/FakeClassnameTags123Api.java | 15 +- .../org/openapitools/client/api/PetApi.java | 120 ++++++++-- .../org/openapitools/client/api/StoreApi.java | 51 +++- .../org/openapitools/client/api/UserApi.java | 108 +++++++-- 6 files changed, 445 insertions(+), 92 deletions(-) diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 89f412c47760..22f651ee1550 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -87,7 +87,11 @@ public HttpResponse call123testSpecialTagsForHttpResponse(@javax.annotation.Nonn GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + if (uuidTest != null) { + httpRequest.getHeaders().set("uuid_test", uuidTest); + } + return httpRequest.execute(); } public HttpResponse call123testSpecialTagsForHttpResponse(@javax.annotation.Nonnull UUID uuidTest, java.io.InputStream body, String mediaType) throws IOException { @@ -106,7 +110,11 @@ public HttpResponse call123testSpecialTagsForHttpResponse(@javax.annotation.Nonn HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + if (uuidTest != null) { + httpRequest.getHeaders().set("uuid_test", uuidTest); + } + return httpRequest.execute(); } public HttpResponse call123testSpecialTagsForHttpResponse(@javax.annotation.Nonnull UUID uuidTest, @javax.annotation.Nonnull Client body, Map params) throws IOException { @@ -141,7 +149,17 @@ public HttpResponse call123testSpecialTagsForHttpResponse(@javax.annotation.Nonn GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + if ("uuid_test".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + } + return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java index a3061d476aae..760785ae3f7d 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java @@ -83,7 +83,8 @@ public HttpResponse createXmlItemForHttpResponse(@javax.annotation.Nonnull XmlIt GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(xmlItem); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createXmlItemForHttpResponse(java.io.InputStream xmlItem, String mediaType) throws IOException { @@ -99,7 +100,8 @@ public HttpResponse createXmlItemForHttpResponse(java.io.InputStream xmlItem, St HttpContent content = xmlItem == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, xmlItem); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createXmlItemForHttpResponse(@javax.annotation.Nonnull XmlItem xmlItem, Map params) throws IOException { @@ -131,7 +133,14 @@ public HttpResponse createXmlItemForHttpResponse(@javax.annotation.Nonnull XmlIt GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(xmlItem); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -169,7 +178,8 @@ public HttpResponse fakeOuterBooleanSerializeForHttpResponse(@javax.annotation.N GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterBooleanSerializeForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -182,7 +192,8 @@ public HttpResponse fakeOuterBooleanSerializeForHttpResponse(java.io.InputStream HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterBooleanSerializeForHttpResponse(@javax.annotation.Nullable Boolean body, Map params) throws IOException { @@ -211,7 +222,14 @@ public HttpResponse fakeOuterBooleanSerializeForHttpResponse(@javax.annotation.N GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -249,7 +267,8 @@ public HttpResponse fakeOuterCompositeSerializeForHttpResponse(@javax.annotation GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterCompositeSerializeForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -262,7 +281,8 @@ public HttpResponse fakeOuterCompositeSerializeForHttpResponse(java.io.InputStre HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterCompositeSerializeForHttpResponse(@javax.annotation.Nullable OuterComposite body, Map params) throws IOException { @@ -291,7 +311,14 @@ public HttpResponse fakeOuterCompositeSerializeForHttpResponse(@javax.annotation GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -329,7 +356,8 @@ public HttpResponse fakeOuterNumberSerializeForHttpResponse(@javax.annotation.Nu GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterNumberSerializeForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -342,7 +370,8 @@ public HttpResponse fakeOuterNumberSerializeForHttpResponse(java.io.InputStream HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterNumberSerializeForHttpResponse(@javax.annotation.Nullable BigDecimal body, Map params) throws IOException { @@ -371,7 +400,14 @@ public HttpResponse fakeOuterNumberSerializeForHttpResponse(@javax.annotation.Nu GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -409,7 +445,8 @@ public HttpResponse fakeOuterStringSerializeForHttpResponse(@javax.annotation.Nu GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterStringSerializeForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -422,7 +459,8 @@ public HttpResponse fakeOuterStringSerializeForHttpResponse(java.io.InputStream HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse fakeOuterStringSerializeForHttpResponse(@javax.annotation.Nullable String body, Map params) throws IOException { @@ -451,7 +489,14 @@ public HttpResponse fakeOuterStringSerializeForHttpResponse(@javax.annotation.Nu GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -487,7 +532,8 @@ public HttpResponse testBodyWithFileSchemaForHttpResponse(@javax.annotation.Nonn GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testBodyWithFileSchemaForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -503,7 +549,8 @@ public HttpResponse testBodyWithFileSchemaForHttpResponse(java.io.InputStream bo HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testBodyWithFileSchemaForHttpResponse(@javax.annotation.Nonnull FileSchemaTestClass body, Map params) throws IOException { @@ -535,7 +582,14 @@ public HttpResponse testBodyWithFileSchemaForHttpResponse(@javax.annotation.Nonn GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -585,7 +639,8 @@ public HttpResponse testBodyWithQueryParamsForHttpResponse(@javax.annotation.Non GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testBodyWithQueryParamsForHttpResponse(@javax.annotation.Nonnull String query, java.io.InputStream body, String mediaType) throws IOException { @@ -615,7 +670,8 @@ public HttpResponse testBodyWithQueryParamsForHttpResponse(@javax.annotation.Non HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testBodyWithQueryParamsForHttpResponse(@javax.annotation.Nonnull String query, @javax.annotation.Nonnull User body, Map params) throws IOException { @@ -652,7 +708,14 @@ public HttpResponse testBodyWithQueryParamsForHttpResponse(@javax.annotation.Non GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -696,7 +759,8 @@ public HttpResponse testClientModelForHttpResponse(@javax.annotation.Nonnull Cli GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testClientModelForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -712,7 +776,8 @@ public HttpResponse testClientModelForHttpResponse(java.io.InputStream body, Str HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testClientModelForHttpResponse(@javax.annotation.Nonnull Client body, Map params) throws IOException { @@ -744,7 +809,14 @@ public HttpResponse testClientModelForHttpResponse(@javax.annotation.Nonnull Cli GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -809,7 +881,8 @@ public HttpResponse testEndpointParametersForHttpResponse(@javax.annotation.Nonn GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testEndpointParametersForHttpResponse(@javax.annotation.Nonnull BigDecimal number, @javax.annotation.Nonnull Double _double, @javax.annotation.Nonnull String patternWithoutDelimiter, @javax.annotation.Nonnull byte[] _byte, Map params) throws IOException { @@ -850,7 +923,14 @@ public HttpResponse testEndpointParametersForHttpResponse(@javax.annotation.Nonn GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -934,7 +1014,14 @@ public HttpResponse testEnumParametersForHttpResponse(@javax.annotation.Nullable GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + if (enumHeaderStringArray != null) { + httpRequest.getHeaders().set("enum_header_string_array", enumHeaderStringArray); + } + if (enumHeaderString != null) { + httpRequest.getHeaders().set("enum_header_string", enumHeaderString); + } + return httpRequest.execute(); } public HttpResponse testEnumParametersForHttpResponse(Map params) throws IOException { @@ -963,7 +1050,20 @@ public HttpResponse testEnumParametersForHttpResponse(Map params GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + if ("enum_header_string_array".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + if ("enum_header_string".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + } + return httpRequest.execute(); } @@ -1055,7 +1155,14 @@ public HttpResponse testGroupParametersForHttpResponse(@javax.annotation.Nonnull GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + if (requiredBooleanGroup != null) { + httpRequest.getHeaders().set("required_boolean_group", requiredBooleanGroup); + } + if (booleanGroup != null) { + httpRequest.getHeaders().set("boolean_group", booleanGroup); + } + return httpRequest.execute(); } public HttpResponse testGroupParametersForHttpResponse(@javax.annotation.Nonnull Integer requiredStringGroup, @javax.annotation.Nonnull Boolean requiredBooleanGroup, @javax.annotation.Nonnull Long requiredInt64Group, Map params) throws IOException { @@ -1097,7 +1204,20 @@ public HttpResponse testGroupParametersForHttpResponse(@javax.annotation.Nonnull GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + if ("required_boolean_group".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + if ("boolean_group".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + } + return httpRequest.execute(); } @@ -1133,7 +1253,8 @@ public HttpResponse testInlineAdditionalPropertiesForHttpResponse(@javax.annotat GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(param); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testInlineAdditionalPropertiesForHttpResponse(java.io.InputStream param, String mediaType) throws IOException { @@ -1149,7 +1270,8 @@ public HttpResponse testInlineAdditionalPropertiesForHttpResponse(java.io.InputS HttpContent content = param == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, param); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testInlineAdditionalPropertiesForHttpResponse(@javax.annotation.Nonnull Map param, Map params) throws IOException { @@ -1181,7 +1303,14 @@ public HttpResponse testInlineAdditionalPropertiesForHttpResponse(@javax.annotat GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(param); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -1222,7 +1351,8 @@ public HttpResponse testJsonFormDataForHttpResponse(@javax.annotation.Nonnull St GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testJsonFormDataForHttpResponse(@javax.annotation.Nonnull String param, @javax.annotation.Nonnull String param2, Map params) throws IOException { @@ -1257,7 +1387,14 @@ public HttpResponse testJsonFormDataForHttpResponse(@javax.annotation.Nonnull St GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -1364,7 +1501,8 @@ public HttpResponse testQueryParameterCollectionFormatForHttpResponse(@javax.ann GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testQueryParameterCollectionFormatForHttpResponse(@javax.annotation.Nonnull List pipe, @javax.annotation.Nonnull List ioutil, @javax.annotation.Nonnull List http, @javax.annotation.Nonnull List url, @javax.annotation.Nonnull List context, Map params) throws IOException { @@ -1418,7 +1556,14 @@ public HttpResponse testQueryParameterCollectionFormatForHttpResponse(@javax.ann GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 3e918fd103a4..00b40009732d 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -81,7 +81,8 @@ public HttpResponse testClassnameForHttpResponse(@javax.annotation.Nonnull Clien GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testClassnameForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -97,7 +98,8 @@ public HttpResponse testClassnameForHttpResponse(java.io.InputStream body, Strin HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + return httpRequest.execute(); } public HttpResponse testClassnameForHttpResponse(@javax.annotation.Nonnull Client body, Map params) throws IOException { @@ -129,7 +131,14 @@ public HttpResponse testClassnameForHttpResponse(@javax.annotation.Nonnull Clien GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java index 750d187510ed..56cff9fb19c1 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java @@ -78,7 +78,8 @@ public HttpResponse addPetForHttpResponse(@javax.annotation.Nonnull Pet body) th GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse addPetForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -94,7 +95,8 @@ public HttpResponse addPetForHttpResponse(java.io.InputStream body, String media HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse addPetForHttpResponse(@javax.annotation.Nonnull Pet body, Map params) throws IOException { @@ -126,7 +128,14 @@ public HttpResponse addPetForHttpResponse(@javax.annotation.Nonnull Pet body, Ma GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -168,7 +177,11 @@ public HttpResponse deletePetForHttpResponse(@javax.annotation.Nonnull Long petI GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + if (apiKey != null) { + httpRequest.getHeaders().set("api_key", apiKey); + } + return httpRequest.execute(); } public HttpResponse deletePetForHttpResponse(@javax.annotation.Nonnull Long petId, Map params) throws IOException { @@ -203,7 +216,17 @@ public HttpResponse deletePetForHttpResponse(@javax.annotation.Nonnull Long petI GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + if ("api_key".equals(key) && value != null) { + httpRequest.getHeaders().set(key, value); + } + } + return httpRequest.execute(); } @@ -260,7 +283,8 @@ public HttpResponse findPetsByStatusForHttpResponse(@javax.annotation.Nonnull Li GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse findPetsByStatusForHttpResponse(@javax.annotation.Nonnull List status, Map params) throws IOException { @@ -294,7 +318,14 @@ public HttpResponse findPetsByStatusForHttpResponse(@javax.annotation.Nonnull Li GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -358,7 +389,8 @@ public HttpResponse findPetsByTagsForHttpResponse(@javax.annotation.Nonnull Set< GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } @Deprecated @@ -393,7 +425,14 @@ public HttpResponse findPetsByTagsForHttpResponse(@javax.annotation.Nonnull Set< GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -444,7 +483,8 @@ public HttpResponse getPetByIdForHttpResponse(@javax.annotation.Nonnull Long pet GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse getPetByIdForHttpResponse(@javax.annotation.Nonnull Long petId, Map params) throws IOException { @@ -479,7 +519,14 @@ public HttpResponse getPetByIdForHttpResponse(@javax.annotation.Nonnull Long pet GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -521,7 +568,8 @@ public HttpResponse updatePetForHttpResponse(@javax.annotation.Nonnull Pet body) GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse updatePetForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -537,7 +585,8 @@ public HttpResponse updatePetForHttpResponse(java.io.InputStream body, String me HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse updatePetForHttpResponse(@javax.annotation.Nonnull Pet body, Map params) throws IOException { @@ -569,7 +618,14 @@ public HttpResponse updatePetForHttpResponse(@javax.annotation.Nonnull Pet body, GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -610,7 +666,8 @@ public HttpResponse updatePetWithFormForHttpResponse(@javax.annotation.Nonnull L GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse updatePetWithFormForHttpResponse(@javax.annotation.Nonnull Long petId, Map params) throws IOException { @@ -645,7 +702,14 @@ public HttpResponse updatePetWithFormForHttpResponse(@javax.annotation.Nonnull L GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -692,7 +756,8 @@ public HttpResponse uploadFileForHttpResponse(@javax.annotation.Nonnull Long pet GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse uploadFileForHttpResponse(@javax.annotation.Nonnull Long petId, Map params) throws IOException { @@ -727,7 +792,14 @@ public HttpResponse uploadFileForHttpResponse(@javax.annotation.Nonnull Long pet GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -778,7 +850,8 @@ public HttpResponse uploadFileWithRequiredFileForHttpResponse(@javax.annotation. GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse uploadFileWithRequiredFileForHttpResponse(@javax.annotation.Nonnull Long petId, @javax.annotation.Nonnull File requiredFile, Map params) throws IOException { @@ -816,7 +889,14 @@ public HttpResponse uploadFileWithRequiredFileForHttpResponse(@javax.annotation. GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java index 961d0f550a67..96296cd5911a 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java @@ -80,7 +80,8 @@ public HttpResponse deleteOrderForHttpResponse(@javax.annotation.Nonnull String GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + return httpRequest.execute(); } public HttpResponse deleteOrderForHttpResponse(@javax.annotation.Nonnull String orderId, Map params) throws IOException { @@ -115,7 +116,14 @@ public HttpResponse deleteOrderForHttpResponse(@javax.annotation.Nonnull String GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -154,7 +162,8 @@ public HttpResponse getInventoryForHttpResponse() throws IOException { GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse getInventoryForHttpResponse(Map params) throws IOException { @@ -183,7 +192,14 @@ public HttpResponse getInventoryForHttpResponse(Map params) thro GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -234,7 +250,8 @@ public HttpResponse getOrderByIdForHttpResponse(@javax.annotation.Nonnull Long o GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse getOrderByIdForHttpResponse(@javax.annotation.Nonnull Long orderId, Map params) throws IOException { @@ -269,7 +286,14 @@ public HttpResponse getOrderByIdForHttpResponse(@javax.annotation.Nonnull Long o GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -313,7 +337,8 @@ public HttpResponse placeOrderForHttpResponse(@javax.annotation.Nonnull Order bo GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse placeOrderForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -329,7 +354,8 @@ public HttpResponse placeOrderForHttpResponse(java.io.InputStream body, String m HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse placeOrderForHttpResponse(@javax.annotation.Nonnull Order body, Map params) throws IOException { @@ -361,7 +387,14 @@ public HttpResponse placeOrderForHttpResponse(@javax.annotation.Nonnull Order bo GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java index c7601f126d3b..735f256940d0 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java @@ -76,7 +76,8 @@ public HttpResponse createUserForHttpResponse(@javax.annotation.Nonnull User bod GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createUserForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -92,7 +93,8 @@ public HttpResponse createUserForHttpResponse(java.io.InputStream body, String m HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createUserForHttpResponse(@javax.annotation.Nonnull User body, Map params) throws IOException { @@ -124,7 +126,14 @@ public HttpResponse createUserForHttpResponse(@javax.annotation.Nonnull User bod GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -160,7 +169,8 @@ public HttpResponse createUsersWithArrayInputForHttpResponse(@javax.annotation.N GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createUsersWithArrayInputForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -176,7 +186,8 @@ public HttpResponse createUsersWithArrayInputForHttpResponse(java.io.InputStream HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createUsersWithArrayInputForHttpResponse(@javax.annotation.Nonnull List body, Map params) throws IOException { @@ -208,7 +219,14 @@ public HttpResponse createUsersWithArrayInputForHttpResponse(@javax.annotation.N GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -244,7 +262,8 @@ public HttpResponse createUsersWithListInputForHttpResponse(@javax.annotation.No GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createUsersWithListInputForHttpResponse(java.io.InputStream body, String mediaType) throws IOException { @@ -260,7 +279,8 @@ public HttpResponse createUsersWithListInputForHttpResponse(java.io.InputStream HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + return httpRequest.execute(); } public HttpResponse createUsersWithListInputForHttpResponse(@javax.annotation.Nonnull List body, Map params) throws IOException { @@ -292,7 +312,14 @@ public HttpResponse createUsersWithListInputForHttpResponse(@javax.annotation.No GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -335,7 +362,8 @@ public HttpResponse deleteUserForHttpResponse(@javax.annotation.Nonnull String u GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + return httpRequest.execute(); } public HttpResponse deleteUserForHttpResponse(@javax.annotation.Nonnull String username, Map params) throws IOException { @@ -370,7 +398,14 @@ public HttpResponse deleteUserForHttpResponse(@javax.annotation.Nonnull String u GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -419,7 +454,8 @@ public HttpResponse getUserByNameForHttpResponse(@javax.annotation.Nonnull Strin GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse getUserByNameForHttpResponse(@javax.annotation.Nonnull String username, Map params) throws IOException { @@ -454,7 +490,14 @@ public HttpResponse getUserByNameForHttpResponse(@javax.annotation.Nonnull Strin GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -524,7 +567,8 @@ public HttpResponse loginUserForHttpResponse(@javax.annotation.Nonnull String us GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse loginUserForHttpResponse(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull String password, Map params) throws IOException { @@ -563,7 +607,14 @@ public HttpResponse loginUserForHttpResponse(@javax.annotation.Nonnull String us GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -594,7 +645,8 @@ public HttpResponse logoutUserForHttpResponse() throws IOException { GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + return httpRequest.execute(); } public HttpResponse logoutUserForHttpResponse(Map params) throws IOException { @@ -623,7 +675,14 @@ public HttpResponse logoutUserForHttpResponse(Map params) throws GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } @@ -671,7 +730,8 @@ public HttpResponse updateUserForHttpResponse(@javax.annotation.Nonnull String u GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse updateUserForHttpResponse(@javax.annotation.Nonnull String username, java.io.InputStream body, String mediaType) throws IOException { @@ -693,7 +753,8 @@ public HttpResponse updateUserForHttpResponse(@javax.annotation.Nonnull String u HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + return httpRequest.execute(); } public HttpResponse updateUserForHttpResponse(@javax.annotation.Nonnull String username, @javax.annotation.Nonnull User body, Map params) throws IOException { @@ -731,7 +792,14 @@ public HttpResponse updateUserForHttpResponse(@javax.annotation.Nonnull String u GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); - return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); + com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); + // Note: Header params passed via 'params' map are handled below + for (Map.Entry entry: params.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + // Check if this is a header parameter by name + } + return httpRequest.execute(); } From 2b74ae2770618524d54bf47e2731cb523d3df486 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 1 Dec 2025 12:53:53 +0800 Subject: [PATCH 3/3] minor enhancement --- .../libraries/google-api-client/api.mustache | 2 + .../org/openapitools/client/api/FakeApi.java | 72 ------------------- .../client/api/FakeClassnameTags123Api.java | 6 -- .../org/openapitools/client/api/PetApi.java | 48 ------------- .../org/openapitools/client/api/StoreApi.java | 24 ------- .../org/openapitools/client/api/UserApi.java | 48 ------------- 6 files changed, 2 insertions(+), 198 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache index e6fd1e44f38d..2b4365bbfa2a 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache @@ -214,6 +214,7 @@ public class {{classname}} { HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}}; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content); + {{#hasHeaderParams}} // Note: Header params passed via 'params' map are handled below for (Map.Entry entry: params.entrySet()) { String key = entry.getKey(); @@ -225,6 +226,7 @@ public class {{classname}} { } {{/headerParams}} } + {{/hasHeaderParams}} return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java index 760785ae3f7d..7ac7c4d4172a 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeApi.java @@ -134,12 +134,6 @@ public HttpResponse createXmlItemForHttpResponse(@javax.annotation.Nonnull XmlIt HttpContent content = apiClient.new JacksonJsonHttpContent(xmlItem); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -223,12 +217,6 @@ public HttpResponse fakeOuterBooleanSerializeForHttpResponse(@javax.annotation.N HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -312,12 +300,6 @@ public HttpResponse fakeOuterCompositeSerializeForHttpResponse(@javax.annotation HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -401,12 +383,6 @@ public HttpResponse fakeOuterNumberSerializeForHttpResponse(@javax.annotation.Nu HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -490,12 +466,6 @@ public HttpResponse fakeOuterStringSerializeForHttpResponse(@javax.annotation.Nu HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -583,12 +553,6 @@ public HttpResponse testBodyWithFileSchemaForHttpResponse(@javax.annotation.Nonn HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -709,12 +673,6 @@ public HttpResponse testBodyWithQueryParamsForHttpResponse(@javax.annotation.Non HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -810,12 +768,6 @@ public HttpResponse testClientModelForHttpResponse(@javax.annotation.Nonnull Cli HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -924,12 +876,6 @@ public HttpResponse testEndpointParametersForHttpResponse(@javax.annotation.Nonn HttpContent content = new EmptyContent(); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -1304,12 +1250,6 @@ public HttpResponse testInlineAdditionalPropertiesForHttpResponse(@javax.annotat HttpContent content = apiClient.new JacksonJsonHttpContent(param); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -1388,12 +1328,6 @@ public HttpResponse testJsonFormDataForHttpResponse(@javax.annotation.Nonnull St HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -1557,12 +1491,6 @@ public HttpResponse testQueryParameterCollectionFormatForHttpResponse(@javax.ann HttpContent content = new EmptyContent(); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 00b40009732d..171f8392839f 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -132,12 +132,6 @@ public HttpResponse testClassnameForHttpResponse(@javax.annotation.Nonnull Clien HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java index 56cff9fb19c1..fc749592d437 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/PetApi.java @@ -129,12 +129,6 @@ public HttpResponse addPetForHttpResponse(@javax.annotation.Nonnull Pet body, Ma HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -319,12 +313,6 @@ public HttpResponse findPetsByStatusForHttpResponse(@javax.annotation.Nonnull Li HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -426,12 +414,6 @@ public HttpResponse findPetsByTagsForHttpResponse(@javax.annotation.Nonnull Set< HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -520,12 +502,6 @@ public HttpResponse getPetByIdForHttpResponse(@javax.annotation.Nonnull Long pet HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -619,12 +595,6 @@ public HttpResponse updatePetForHttpResponse(@javax.annotation.Nonnull Pet body, HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -703,12 +673,6 @@ public HttpResponse updatePetWithFormForHttpResponse(@javax.annotation.Nonnull L HttpContent content = new EmptyContent(); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -793,12 +757,6 @@ public HttpResponse uploadFileForHttpResponse(@javax.annotation.Nonnull Long pet HttpContent content = new EmptyContent(); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -890,12 +848,6 @@ public HttpResponse uploadFileWithRequiredFileForHttpResponse(@javax.annotation. HttpContent content = new EmptyContent(); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java index 96296cd5911a..71f2ca5a8411 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/StoreApi.java @@ -117,12 +117,6 @@ public HttpResponse deleteOrderForHttpResponse(@javax.annotation.Nonnull String HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -193,12 +187,6 @@ public HttpResponse getInventoryForHttpResponse(Map params) thro HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -287,12 +275,6 @@ public HttpResponse getOrderByIdForHttpResponse(@javax.annotation.Nonnull Long o HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -388,12 +370,6 @@ public HttpResponse placeOrderForHttpResponse(@javax.annotation.Nonnull Order bo HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java index 735f256940d0..0223f9f5821a 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/api/UserApi.java @@ -127,12 +127,6 @@ public HttpResponse createUserForHttpResponse(@javax.annotation.Nonnull User bod HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -220,12 +214,6 @@ public HttpResponse createUsersWithArrayInputForHttpResponse(@javax.annotation.N HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -313,12 +301,6 @@ public HttpResponse createUsersWithListInputForHttpResponse(@javax.annotation.No HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -399,12 +381,6 @@ public HttpResponse deleteUserForHttpResponse(@javax.annotation.Nonnull String u HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.DELETE, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -491,12 +467,6 @@ public HttpResponse getUserByNameForHttpResponse(@javax.annotation.Nonnull Strin HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -608,12 +578,6 @@ public HttpResponse loginUserForHttpResponse(@javax.annotation.Nonnull String us HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -676,12 +640,6 @@ public HttpResponse logoutUserForHttpResponse(Map params) throws HttpContent content = null; com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); } @@ -793,12 +751,6 @@ public HttpResponse updateUserForHttpResponse(@javax.annotation.Nonnull String u HttpContent content = apiClient.new JacksonJsonHttpContent(body); com.google.api.client.http.HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content); - // Note: Header params passed via 'params' map are handled below - for (Map.Entry entry: params.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - // Check if this is a header parameter by name - } return httpRequest.execute(); }