forked from loafle/openapi-generator-original
[Java] fix runtime exception when there are multiple auth methods (#5530)
* fix runtime exception when there are multiple auth methods * Refactor a bit so that it does not cause conflict with relative url token branch
This commit is contained in:
@@ -153,6 +153,10 @@ public class ApiClient {
|
||||
);
|
||||
initHttpClient(Collections.<Interceptor>singletonList(retryingOAuth));
|
||||
{{/hasOAuthMethods}}
|
||||
// Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
||||
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
|
||||
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
|
||||
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{/authMethods}}
|
||||
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
|
||||
@@ -143,6 +143,10 @@ public class ApiClient {
|
||||
retryingOAuth
|
||||
);
|
||||
initHttpClient(Collections.<Interceptor>singletonList(retryingOAuth));
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("api_key_query", new ApiKeyAuth("query", "api_key_query"));
|
||||
authentications.put("http_basic_test", new HttpBasicAuth());
|
||||
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
|
||||
@@ -143,6 +143,10 @@ public class ApiClient {
|
||||
retryingOAuth
|
||||
);
|
||||
initHttpClient(Collections.<Interceptor>singletonList(retryingOAuth));
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||
authentications.put("api_key_query", new ApiKeyAuth("query", "api_key_query"));
|
||||
authentications.put("http_basic_test", new HttpBasicAuth());
|
||||
|
||||
// Prevent the authentications from being modified.
|
||||
authentications = Collections.unmodifiableMap(authentications);
|
||||
|
||||
Reference in New Issue
Block a user