This commit is contained in:
William Cheng 2020-06-15 09:47:20 +08:00
commit 6c24239bac
3 changed files with 51 additions and 0 deletions

View File

@ -102,6 +102,23 @@ public class ApiClient {
authentications = Collections.unmodifiableMap(authentications);
}
/*
* Basic constructor with custom OkHttpClient
*/
public ApiClient(OkHttpClient client) {
init();
httpClient = client;
// 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}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
{{#hasOAuthMethods}}
{{#oauthMethods}}
{{#-first}}

View File

@ -97,6 +97,23 @@ public class ApiClient {
authentications = Collections.unmodifiableMap(authentications);
}
/*
* Basic constructor with custom OkHttpClient
*/
public ApiClient(OkHttpClient client) {
init();
httpClient = client;
// 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());
authentications.put("petstore_auth", new OAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
/*
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID
*/

View File

@ -97,6 +97,23 @@ public class ApiClient {
authentications = Collections.unmodifiableMap(authentications);
}
/*
* Basic constructor with custom OkHttpClient
*/
public ApiClient(OkHttpClient client) {
init();
httpClient = client;
// 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());
authentications.put("petstore_auth", new OAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
/*
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID
*/