Open hatzlj opened 5 years ago
Same happens also within the constructor when adding the RetryingOauth
interceptor
public ApiClient(String clientId, String clientSecret, Map<String, String> parameters) {
init();
RetryingOAuth retryingOAuth = new RetryingOAuth("/api/v1/oauth2/token", clientId, OAuthFlow.password, clientSecret, parameters);
authentications.put(
"myAuth",
retryingOAuth
);
httpClient.interceptors().add(retryingOAuth);
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
will add a separate Bug report if necessary when this one is verified.
fix the ApiClient Mustache Template in line 147 to add the GzipRequestInterceptor before the builder is built
@hatzlj please file a PR so that we can review the fix more easily.
ok, i will try to do so as soon as possible
Any update on this? My team currently ran into this issue and we would like a fix in
I provided the referenced pull request to fix this issue. Waiting for approval and merge by maintainers.
Description
When instantiating a java/okhttp based client (generated with 'useGzipFeature' enabled) with parameters for oauth authentication, the constructor throws a
java.lang.UnsupportedOperationException
because the generated ApiClient tries to add theGzipRequestInterceptor' to an Unmodifiable Collection of the 'OkHttpClient
.The error originates in the generated code of the ApiClient during initialization, because
httpClient.interceptors().add(...)
is called afterhttpClient = builder.build();
:openapi-generator version
4.0.0
OpenAPI declaration file content or url
Command line used for generation
used via the openapi-generator-maven-plugin
Steps to reproduce
acutal output:
java.lang.UnsupportedOperationException
expected output: client is instantiated with specified parameters for OAuthRelated issues/PRs
see also https://github.com/square/okhttp/issues/2219
Suggest a fix
fix the ApiClient Mustache Template in line 147 to add the GzipRequestInterceptor before the builder is built