mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 23:17:04 +00:00
Jersey2: Move setting of authentication parameters before generating target URL to consider API keys in URL parameters (#20688)
* Move setting of authentication parameters before generating target URL to consider API keys in URL parameters * Regenerate Jersey2/3 examples
This commit is contained in:
@@ -1235,6 +1235,22 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
// put all headers in one place
|
||||
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
|
||||
allHeaderParams.putAll(headerParams);
|
||||
|
||||
if (authNames != null) {
|
||||
// update different parameters (e.g. headers) for authentication
|
||||
updateParamsForAuth(
|
||||
authNames,
|
||||
queryParams,
|
||||
allHeaderParams,
|
||||
cookieParams,
|
||||
serializeToString(body, formParams, contentType, isBodyNullable),
|
||||
method,
|
||||
target.getUri());
|
||||
}
|
||||
|
||||
if (queryParams != null) {
|
||||
for (Pair queryParam : queryParams) {
|
||||
if (queryParam.getValue() != null) {
|
||||
@@ -1265,22 +1281,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
|
||||
Entity<?> entity = serialize(body, formParams, contentType, isBodyNullable);
|
||||
|
||||
// put all headers in one place
|
||||
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
|
||||
allHeaderParams.putAll(headerParams);
|
||||
|
||||
if (authNames != null) {
|
||||
// update different parameters (e.g. headers) for authentication
|
||||
updateParamsForAuth(
|
||||
authNames,
|
||||
queryParams,
|
||||
allHeaderParams,
|
||||
cookieParams,
|
||||
serializeToString(body, formParams, contentType, isBodyNullable),
|
||||
method,
|
||||
target.getUri());
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : allHeaderParams.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
if (value != null) {
|
||||
|
||||
Reference in New Issue
Block a user