[BUG] Java (jersey2) ApiClient debug cannot be enabled
Created by: tomred-net
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The generated client code for java (using jersey) has a bug. You cannot enable debug for the client requests. When setting debug to true setDebugging(true)
the setter has a side-effect of also recreating the httpClient by calling buildHttpClient()
. The call to buildHttpClient()
is desirable but the method contains an if block which prevents the call to getDefaultClientConfig()
if it is already set favouring the existing config.
// use the default client config if not yet initialized
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
Unfortunately this skips enabling the debug settings which is set within the getDefaultClientConfig()
method.
I will prepare a PR which removes this check resulting in the creation of a new clientConfig
on each call to buildHttpClient()
which I believe is the intended outcome.
openapi-generator version
openapi-generator v5.0.0+
OpenAPI declaration file content or url
Generation Details
-g java --additional-properties=library=jersey2
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java --additional-properties=library=jersey2 -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o ~/tmp/java-client-test
Steps to reproduce
run the command above
Related issues/PRs
Suggest a fix
I'm preparing a PR which will remove the check
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}