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 swagger nxx response #345

Merged
merged 4 commits into from
Jan 30, 2021
Merged

Fix swagger nxx response #345

merged 4 commits into from
Jan 30, 2021

Conversation

climba03003
Copy link
Member

@climba03003 climba03003 commented Jan 30, 2021

Resolve: #250

Caption from swagger
To define a range of response codes, you may use the following range definitions: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.

I do not introduce a new option as @Eomm suggestion. It will also not throwing error because it may break someone code.

Behavior for Swagger

  • When I see Nxx status code, transform it to 200 status code.
  • If we find conflict of 200 status code, drop the transformed one as it is more general response.
  • Append the transformed status code to response.

Behavior for OpenAPI

  • All Nxx status code will enforce upper case.
  • Append the transformed status code to response.

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Can you please add a unit test?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit aa496a9 into fastify:master Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manage 2xx in response
2 participants