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
  • #12205
Closed
Open
Issue created Apr 22, 2022 by Administrator@rootContributor

[BUG][JAVA] ApiException does not include any HTTP response info in getMessage()

Created by: panargirakis

Description

The HTTP response code, response body or response headers are completely absent from the exception printout when an ApiException occurs making debugging very difficult.

This issue could instead be considered a feature request but I consider it a bug due to how severely it impacts the debugging/root cause analysis workflow.

This happens because ApiException.java class uses the default getMessage() method from super which only includes the message attribute.

openapi-generator version

Versions 5.4.0 and 6.0.0-beta exhibit this behavior.

OpenAPI declaration file content or url

Full schema here

Generation Details

Run the following script:

curl https://gist.githubusercontent.com/panargirakis/0d465f954f2c913ef3fc379f1b63da91/raw/0135da54dc950da698e8104bad88ed52af5a6aa6/ResSystem_Schema_2.1.0.yml -o ./latest_schema.yml
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v5.4.0 generate -i /local/latest_schema.yml -g java -o /local/
Related issues/PRs

None I am aware of.

Suggest a fix

Override getMessage() in ApiException.java similarly to:

public String getMessage() {
        return String.format("\nCode: %s\nMessage: %s\nResponseBody: %s\nResponseHeaders: %s\n",
                this.getCode(), super.getMessage(), this.getResponseBody(), this.getResponseHeaders().toString());
    }
Assignee
Assign to
Time tracking