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:
jheyens
2025-04-23 10:04:26 +02:00
committed by GitHub
parent d2e20253e4
commit e767496357
13 changed files with 218 additions and 218 deletions

View File

@@ -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) {