You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
protected Map<String,ApiOperation> operationLookupMap = new HashMap<>();
139
139
140
140
{{/dynamicOperations}}
141
-
/**
142
-
* Basic constructor for ApiClient
141
+
{{! BEGIN - Removed ApiClient constructor and replaced it with a custom constructors which create the ApiClient with the CoreConfiguration }}
142
+
/**
143
+
* Basic constructor for ApiClient.
144
+
*
145
+
* Not recommended for production use, use the one with the OkHttpClient parameter instead.
146
+
*
147
+
* @throws IOException thrown when a file can not be found
143
148
*/
144
149
public ApiClient() throws IOException {
145
-
{{! BEGIN - replace basic constructur }}
146
-
this(new CoreConfiguration());
147
-
{{! END - replace basic constructur }}
150
+
this(null, new CoreConfiguration());
148
151
}
149
152
150
-
{{! BEGIN - Removed ApiClient constructor with OkHttpClient as param and replaced it with a custom constructor which creates the ApiClient with the CoreConfiguration }}
151
153
/**
152
-
* Basic constructor with custom CoreConfiguration
153
-
*
154
-
* @param config a {@link cloud.stackit.sdk.core.config} object
155
-
* @throws IOException thrown when a file can not be found
156
-
*/
154
+
* Basic constructor for ApiClient
155
+
*
156
+
* Not recommended for production use, use the one with the OkHttpClient parameter instead.
157
+
*
158
+
* @param config a {@link cloud.stackit.sdk.core.config.CoreConfiguration} object
159
+
* @throws IOException thrown when a file can not be found
160
+
*/
157
161
public ApiClient(CoreConfiguration config) throws IOException {
162
+
this(null, config);
163
+
}
164
+
165
+
/**
166
+
* Constructor for ApiClient with OkHttpClient parameter. Recommended for production use.
167
+
*
168
+
* @param httpClient a OkHttpClient object
169
+
* @throws IOException thrown when a file can not be found
170
+
*/
171
+
public ApiClient(OkHttpClient httpClient) throws IOException {
172
+
this(httpClient, new CoreConfiguration());
173
+
}
174
+
175
+
/**
176
+
* Constructor for ApiClient with OkHttpClient parameter. Recommended for production use.
177
+
*
178
+
* @param httpClient a OkHttpClient object
179
+
* @param config a {@link cloud.stackit.sdk.core.config.CoreConfiguration} object
180
+
* @throws IOException thrown when a file can not be found
181
+
*/
182
+
public ApiClient(OkHttpClient httpClient, CoreConfiguration config) throws IOException {
158
183
init();
159
184
160
-
if (config.getCustomEndpoint() != null &&!config.getCustomEndpoint().trim().isEmpty()) {
161
-
basePath = config.getCustomEndpoint();
162
-
}
163
-
if (config.getDefaultHeader() != null) {
164
-
defaultHeaderMap = config.getDefaultHeader();
165
-
}
185
+
if (config.getCustomEndpoint() != null &&!config.getCustomEndpoint().trim().isEmpty()) {
186
+
basePath = config.getCustomEndpoint();
187
+
}
188
+
if (config.getDefaultHeader() != null) {
189
+
defaultHeaderMap = config.getDefaultHeader();
190
+
}
166
191
this.configuration = config;
167
192
168
-
// Setup AuthHandler
169
-
SetupAuth auth;
170
-
auth = new SetupAuth(config);
171
-
auth.init();
172
-
authenticationInterceptor = auth;
173
-
174
-
initHttpClient();
193
+
if (httpClient == null) {
194
+
initHttpClient();
195
+
KeyFlowAuthenticator authenticator = new KeyFlowAuthenticator(this.httpClient, config);
// Authorization has to be configured manually in case a custom http client object is passed
199
+
this.httpClient = httpClient;
200
+
}
175
201
}
176
-
{{! END - Removed ApiClient constructor with OkHttpClient as param and replaced it with a custom constructor which creates the ApiClient with the CoreConfiguration }}
202
+
{{! END - Removed ApiClient constructor and replaced it with a custom constructors which create the ApiClient with the CoreConfiguration }}
{{! This template had to be customized because of our changes to the DefaultApi and ApiClient classes }}
2
+
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.15.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api_test.mustache }}
0 commit comments