Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Java (jersey2) ApiClient debug cannot be enabled #8755

Closed
5 of 6 tasks
tomred-net opened this issue Feb 18, 2021 · 1 comment · Fixed by #8756
Closed
5 of 6 tasks

[BUG] Java (jersey2) ApiClient debug cannot be enabled #8755

tomred-net opened this issue Feb 18, 2021 · 1 comment · Fixed by #8756

Comments

@tomred-net
Copy link
Contributor

tomred-net commented Feb 18, 2021

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

https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

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();
}
@auto-labeler
Copy link

auto-labeler bot commented Feb 18, 2021

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@tomred-net tomred-net changed the title [BUG] Java ApiClient debug cannot be enabled [BUG] Java (jersey2) ApiClient debug cannot be enabled Feb 18, 2021
tomred-net added a commit to tomred-net/openapi-generator that referenced this issue Feb 22, 2021
tomred-net added a commit to tomred-net/openapi-generator that referenced this issue Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant