Skip to content

feat: Add more swagger checks #5707

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

Merged
merged 5 commits into from
Jan 13, 2023
Merged

feat: Add more swagger checks #5707

merged 5 commits into from
Jan 13, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Jan 13, 2023

This PR improves the swagger validator with extra checks (thanks @mafredri for ideas!):

  1. Ensure single annotations for swagger comment block.
  2. Enforce set of allowed values for @Produce.

@mtojek mtojek self-assigned this Jan 13, 2023
@mtojek mtojek requested a review from mafredri January 13, 2023 14:23
@mtojek mtojek marked this pull request as ready for review January 13, 2023 14:27
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

I love that this is ensured with tests!

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Nice improvements 👍🏻.

I can still get "Missing [at]Router annotation" by typing it wrong, like:

// @Router /users/firsts [gets]

(gets vs get).

@mtojek
Copy link
Member Author

mtojek commented Jan 13, 2023

I can still get "Missing [at]Router annotation" by typing it wrong, like:

It works as intended. Consider the following case:

// @Router /users/firsts [gets]

// @Router /users/firsts [post]

// @Router /users/firsts [foobar]

The validator is not able to figure out if gets is a mistake or if it's a real function, but it's absolutely valid case that all three methods are there. I can improve it in a follow-up if you have an idea.

@mtojek mtojek merged commit dad242a into coder:main Jan 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants