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

Fix: Markdown and Console renderer fail when processing range HTTP status code e. g. '2XX' #397

Merged
merged 3 commits into from
Jul 25, 2022

Conversation

TimoBehrendt
Copy link
Contributor

Description

Both Markdown and Console renderer fail when trying to process a range HTTP status code, e. g. '2XX'. So any diff that results in an output including such a status code fails to render for markdown and console.
The error occurs when trying to parse the String HTTP status code into an Integer right here (both in Markdown and Console renderer):

if (!code.equals("default")) {
     // Integer.parseInt(code) fails when passing e. g. '2XX'
    status = HttpStatus.getReasonPhrase(Integer.parseInt(code));
}

JSON and HTML renderer are not affected, since they do not try to display the 'reason phrase'. Everything else, the actual diff process etc. is also not affected.

Expected behavior

Expected ranges of HTTP status codes, like '2XX' covering all codes between 200-299, to be treated like any other HTTP status code, since they have been part of the OpenAPI specification since version 3.0.0.

Has this been tested?

I've added tests to both renderers with a corresponding test specification checking if the renderer fails.

Checklist:

  • Smaller changes are easier to review
  • Add test case(s) to cover the change
  • Document the fix in the code to make the code more readable
    • Not worth a comment
  • Make sure test cases passed after the change
  • File a PR with meaningful title, description and commit messages
    • I hope I did.
  • Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.

A review, feedback and merge is highly appreciated.

@gitpod-io
Copy link

gitpod-io bot commented Jul 24, 2022

@joschi joschi added this to the 2.1.0 milestone Jul 25, 2022
@joschi joschi added the bug label Jul 25, 2022
Copy link
Contributor

@joschi joschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimoBehrendt LGTM, thanks! 😄

@joschi joschi merged commit da18a85 into OpenAPITools:master Jul 25, 2022
@TimoBehrendt
Copy link
Contributor Author

No worries, thank you for the quick review & merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants