forked from loafle/openapi-generator-original
[Java] Add add constructor to BYO OkHttpClient (#6401)
* [Java] Add add constructor to BYO OkHttpClient * client example * this client changed too
This commit is contained in:
parent
171337e5f3
commit
1a2097e81d
@ -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}}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user