Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Validate swagger definitions#5694

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mtojek merged 70 commits intocoder:mainfrommtojek:3522-validation
Jan 13, 2023
Merged

Conversation

mtojek
Copy link
Member

@mtojekmtojek commentedJan 12, 2023
edited
Loading

Fixes:#3522

This PR concludes the autogenerating docs initiative with a basic Swagger validator and custom rules, that will let us keep the better quality of docs. The validator usesgo/ast to parse comments and Go structure fields. It covers OSS and Enterprisechi handlers.

Checks:

  1. Ensure consistency between@Summary and@ID.
  2. Verify@Success and/or@Failure.
  3. Verify presence of required annotations.
  4. Make sure that Go comment (above the function) is before swagger's@...
  5. Ensure that path parameters are defined.
  6. Ensure that@Security tag is present.
  7. Verify@Accept annotation.
  8. Verify@Produce annotation.
  9. Ensure unique swagger routes - no copy/paste mistakes.
  10. Make sure thatuuid.UUID andtime.Time fields are formatted.

To reviewer:

  • There are many files in this PR, mainly due to minor fixes spotted while implementing the validator. I suggest starting the peer review withcoderdtest/swaggerparser.go.

kylecarbs reacted with eyes emoji
@mtojekmtojek self-assigned thisJan 12, 2023
@mtojekmtojek changed the titleValidatefeat: Validate swagger definitionsJan 12, 2023
@mtojekmtojek mentioned this pull requestJan 12, 2023
29 tasks
@mtojekmtojek requested review froma team,sreya,mafredri andcoadler and removed request fora team andsreyaJanuary 12, 2023 17:11
@mtojekmtojek marked this pull request as ready for reviewJanuary 12, 2023 17:12
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

I haven't gone through the generated docs with a fine-toothed comb, but I just had a couple of questions/observations about the Swagger parser.

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

This is pretty neat 👍

mtojek reacted with heart emoji
@mtojekmtojek merged commitdeebfcb intocoder:mainJan 13, 2023
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJan 13, 2023
@Emyrk
Copy link
Member

Emyrk commentedJan 13, 2023
edited
Loading

Love how easily the go parser was to get comment groups.

I would suggest we should comment what each assertion does. Some are obvious, but it would be helpful to have some english.

Do you intend to parse the go code at all? Like enforce all routes have a swagger defintion? I missed the Chi walker at first. Neat!

Do you intend to dig into the functions and seeing if the return type is called viahttapi.Write? Curious if you think we should do any more analysis on the types, via the SDK or the route functions.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@mafredrimafredriAwaiting requested review from mafredri

@coadlercoadlerAwaiting requested review from coadler

Assignees

@mtojekmtojek

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Autogenerated docs for REST API
3 participants
@mtojek@Emyrk@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp