-
Notifications
You must be signed in to change notification settings - Fork 18
Add spectral rules #20 #229
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
justinyoo
merged 5 commits into
aliencube:main
from
tae0y:feature/20-openapi-doc-review
Aug 19, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Source: https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules | ||
extends: | ||
- spectral:oas | ||
rules: | ||
# API 버전 규칙 : v로 시작하고 숫자와 점으로 이루어져야 함 | ||
api-version-convention: | ||
justinyoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: API version should follow the convention | ||
given: $.info.version | ||
severity: error | ||
then: | ||
function: pattern | ||
functionOptions: | ||
match: "^v[0-9\\.]+$" | ||
message: API version should follow the convention v1, v2.1, v3.0.1, etc. | ||
|
||
# 모든 엔드포인트는 tags를 포함해야 함 | ||
operation-tags-convention: | ||
description: All Operation should include tags | ||
given: $.paths[*][*] | ||
severity: error | ||
then: | ||
- field: tags | ||
function: truthy | ||
message: Tags are required | ||
|
||
# 모든 엔드포인트는 operationId를 포함해야 함 (.WithName 으로 지정) | ||
operation-operationid-convention: | ||
description: All Operation should include operationId | ||
given: $.paths[*][*] | ||
severity: error | ||
then: | ||
- field: operationId | ||
function: truthy | ||
message: OperationId is required | ||
|
||
# 모든 엔드포인트는 summary와 description을 포함해야 함 | ||
operation-summary-description-convention: | ||
description: All Operation should include summary and description | ||
given: $.paths[*][*] | ||
severity: error | ||
then: | ||
- field: 'summary' | ||
function: truthy | ||
message: Summary is required | ||
- field: 'description' | ||
function: truthy | ||
message: Description is required | ||
|
||
# 응답이 정의되어 있어야함 | ||
operation-response-convention: | ||
description: All Operation should include response | ||
given: $.paths[*][*] | ||
severity: error | ||
then: | ||
- field: responses | ||
function: truthy | ||
message: Responses are required | ||
|
||
# 응답 코드 규칙 : 200, 401, 500 응답 코드가 있어야 함 | ||
operation-responsecode-convention: | ||
description: All Operation response should include 200, 401, 500 | ||
given: $.paths[*][*].responses | ||
severity: error | ||
then: | ||
- field: '200' | ||
function: truthy | ||
message: Response 200 is required | ||
- field: '401' | ||
function: truthy | ||
message: Response 401 is required | ||
- field: '500' | ||
function: truthy | ||
message: Response 500 is required | ||
|
||
# 401을 제외한 모든 응답 코드는 content를 포함해야함 | ||
operation-responsedetail-content-convention: | ||
description: All Operation response might include content, except 401 | ||
given: $.paths[*][*].responses[?(@property != '401')] | ||
severity: error | ||
then: | ||
- field: 'content' | ||
function: truthy | ||
message: Content is required |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.