Skip to content

Commit 605eda6

Browse files
committed
moved header population to utility method
1 parent 37eabc6 commit 605eda6

File tree

1 file changed

+12
-5
lines changed
  • modules/openapi-generator/src/main/resources/Java/libraries/native

1 file changed

+12
-5
lines changed

modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ import java.util.function.Consumer;
5353
import java.util.concurrent.CompletableFuture;
5454
{{/asyncNative}}
5555

56+
static class HttpRequestBuilderExtensions {
57+
static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map<String, String> headers) {
58+
if (headers != null) {
59+
for (Map.Entry<String, String> entry : headers.entrySet()) {
60+
builder.header(entry.getKey(), entry.getValue());
61+
}
62+
}
63+
return builder;
64+
}
65+
}
66+
5667
{{>generatedAnnotation}}
5768
{{#operations}}
5869
public class {{classname}} {
@@ -677,11 +688,7 @@ public class {{classname}} {
677688
localVarRequestBuilder.timeout(memberVarReadTimeout);
678689
}
679690
// Add custom headers if provided
680-
if (headers != null) {
681-
for (Map.Entry<String, String> entry : headers.entrySet()) {
682-
localVarRequestBuilder.header(entry.getKey(), entry.getValue());
683-
}
684-
}
691+
localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers);
685692
if (memberVarInterceptor != null) {
686693
memberVarInterceptor.accept(localVarRequestBuilder);
687694
}

0 commit comments

Comments
 (0)