Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Respect User Supplied Header Params #20042

Merged
merged 4 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/utils/test_file_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java"
sha256: e673d9928c8eb848262d0116fe0d28db832e128671a810a7c966d06d90cb9b63
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: 0d64cdc11809a7b5b952ccdad2bd91bd0045b3894d6fabf3e368fa0be12b8217
sha256: 8b1b8f2a2ad00ccb090873a94a5f73e328b98317d2ec715f53bd7a1accb2a023
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/PetTest.java"
sha256: a1f8a70bf7b0c382a8def5bacf7b1fb189e687fabb40235aa799001e0597f545
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ public class {{classname}} {

{{/isQueryParam}}
{{/constantParams}}
{{#headerParams}}
if ({{paramName}} != null) {
localVarHeaderParams.put("{{baseName}}", localVarApiClient.parameterToString({{paramName}}));
}

{{/headerParams}}
{{#constantParams}}
{{#isHeaderParam}}
// Set client side default value of Header Param "{{baseName}}".
Expand Down Expand Up @@ -230,6 +224,13 @@ public class {{classname}} {
if (localVarContentType != null) {
localVarHeaderParams.put("Content-Type", localVarContentType);
}
{{#headerParams}}

if ({{paramName}} != null) {
localVarHeaderParams.put("{{baseName}}", localVarApiClient.parameterToString({{paramName}}));
}

{{/headerParams}}

String[] localVarAuthNames = new String[] { {{#withAWSV4Signature}}"AWS4Auth"{{/withAWSV4Signature}}{{#authMethods}}{{#-first}}{{#withAWSV4Signature}}, {{/withAWSV4Signature}}{{/-first}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };
return localVarApiClient.buildCall(basePath, localVarPath, {{^dynamicOperations}}"{{httpMethod}}"{{/dynamicOperations}}{{#dynamicOperations}}apiOperation.getMethod(){{/dynamicOperations}}, localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ paths:
schema:
type: integer
format: int64
- name: Content-Type
in: header
style: simple
description: Content type header parameter
required: false
schema:
type: string
responses:
'200':
description: successful operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -260,6 +256,11 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}


String[] localVarAuthNames = new String[] { "petstore_auth" };
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,40 +113,45 @@ public okhttp3.Call testHeaderIntegerBooleanStringEnumsCall(Integer integerHeade
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

final String[] localVarAccepts = {
"text/plain"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}

final String[] localVarContentTypes = {
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
if (localVarContentType != null) {
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (integerHeader != null) {
localVarHeaderParams.put("integer_header", localVarApiClient.parameterToString(integerHeader));
}


if (booleanHeader != null) {
localVarHeaderParams.put("boolean_header", localVarApiClient.parameterToString(booleanHeader));
}


if (stringHeader != null) {
localVarHeaderParams.put("string_header", localVarApiClient.parameterToString(stringHeader));
}


if (enumNonrefStringHeader != null) {
localVarHeaderParams.put("enum_nonref_string_header", localVarApiClient.parameterToString(enumNonrefStringHeader));
}


if (enumRefStringHeader != null) {
localVarHeaderParams.put("enum_ref_string_header", localVarApiClient.parameterToString(enumRefStringHeader));
}

final String[] localVarAccepts = {
"text/plain"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}

final String[] localVarContentTypes = {
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
if (localVarContentType != null) {
localVarHeaderParams.put("Content-Type", localVarContentType);
}

String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,6 @@ public okhttp3.Call refToRefParameterCall(UUID refToUuid, final ApiCallback _cal
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (refToUuid != null) {
localVarHeaderParams.put("ref_to_uuid", localVarApiClient.parameterToString(refToUuid));
}

final String[] localVarAccepts = {
"text/plain"
};
Expand All @@ -825,6 +821,11 @@ public okhttp3.Call refToRefParameterCall(UUID refToUuid, final ApiCallback _cal
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (refToUuid != null) {
localVarHeaderParams.put("ref_to_uuid", localVarApiClient.parameterToString(refToUuid));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down Expand Up @@ -932,10 +933,6 @@ public okhttp3.Call refToRefParameterAnyofCall(RefToRefParameterAnyofRefToAnyofP
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (refToAnyof != null) {
localVarHeaderParams.put("ref_to_anyof", localVarApiClient.parameterToString(refToAnyof));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -950,6 +947,11 @@ public okhttp3.Call refToRefParameterAnyofCall(RefToRefParameterAnyofRefToAnyofP
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (refToAnyof != null) {
localVarHeaderParams.put("ref_to_anyof", localVarApiClient.parameterToString(refToAnyof));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down Expand Up @@ -1053,10 +1055,6 @@ public okhttp3.Call refToRefParameterOneofCall(RefRefToPathLevelParameterOneofRe
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (refToOneof != null) {
localVarHeaderParams.put("ref_to_oneof", localVarApiClient.parameterToString(refToOneof));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -1071,6 +1069,11 @@ public okhttp3.Call refToRefParameterOneofCall(RefRefToPathLevelParameterOneofRe
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (refToOneof != null) {
localVarHeaderParams.put("ref_to_oneof", localVarApiClient.parameterToString(refToOneof));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -260,6 +256,11 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}


String[] localVarAuthNames = new String[] { "petstore_auth" };
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -260,6 +256,11 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}


String[] localVarAuthNames = new String[] { "AWS4Auth", "petstore_auth" };
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public okhttp3.Call call123testSpecialTagsCall(UUID uuidTest, Client body, final
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (uuidTest != null) {
localVarHeaderParams.put("uuid_test", localVarApiClient.parameterToString(uuidTest));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, apiOperation.getMethod(), localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,16 @@ public okhttp3.Call testEnumParametersCall(List<String> enumHeaderStringArray, S
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (enumHeaderStringArray != null) {
localVarHeaderParams.put("enum_header_string_array", localVarApiClient.parameterToString(enumHeaderStringArray));
}


if (enumHeaderString != null) {
localVarHeaderParams.put("enum_header_string", localVarApiClient.parameterToString(enumHeaderString));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, apiOperation.getMethod(), localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down Expand Up @@ -1580,6 +1590,16 @@ private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolea
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (requiredBooleanGroup != null) {
localVarHeaderParams.put("required_boolean_group", localVarApiClient.parameterToString(requiredBooleanGroup));
}


if (booleanGroup != null) {
localVarHeaderParams.put("boolean_group", localVarApiClient.parameterToString(booleanGroup));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, apiOperation.getMethod(), localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}
ckoegel marked this conversation as resolved.
Show resolved Hide resolved


String[] localVarAuthNames = new String[] { "petstore_auth" };
return localVarApiClient.buildCall(basePath, localVarPath, apiOperation.getMethod(), localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ private okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -277,6 +273,11 @@ private okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}


String[] localVarAuthNames = new String[] { "petstore_auth" };
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}

final String[] localVarAccepts = {
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
Expand All @@ -250,6 +246,11 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (apiKey != null) {
localVarHeaderParams.put("api_key", localVarApiClient.parameterToString(apiKey));
}


String[] localVarAuthNames = new String[] { "petstore_auth" };
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ public okhttp3.Call call123testSpecialTagsCall(UUID uuidTest, Client body, final
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (uuidTest != null) {
localVarHeaderParams.put("uuid_test", localVarApiClient.parameterToString(uuidTest));
}

final String[] localVarAccepts = {
"application/json"
};
Expand All @@ -131,6 +127,11 @@ public okhttp3.Call call123testSpecialTagsCall(UUID uuidTest, Client body, final
localVarHeaderParams.put("Content-Type", localVarContentType);
}

if (uuidTest != null) {
localVarHeaderParams.put("uuid_test", localVarApiClient.parameterToString(uuidTest));
}


String[] localVarAuthNames = new String[] { };
return localVarApiClient.buildCall(basePath, localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
Expand Down
Loading
Loading