Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8755
Closed
Open
Issue created Feb 18, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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

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();
}
Assignee
Assign to
Time tracking