forked from aliencube/azure-openai-sdk-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
related to aliencube#20, aliencube#21 필수 필드를 지정하고, 해당 필드가 없을 경우 에러를 발생시키도록 수정
- Loading branch information
Showing
1 changed file
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,115 @@ | ||
extends: | ||
- spectral:oas | ||
rules: | ||
# API 버전 규칙 : v로 시작하고 숫자와 점으로 이루어져야 함 | ||
api-version-convention: | ||
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 | ||
|
||
# Post 요청의 경우 requestbody가 정의되어 있어야함 | ||
operation-request-convention: | ||
description: Post Operation should include request body | ||
given: $.paths[*].post | ||
severity: error | ||
then: | ||
- field: requestBody | ||
function: truthy | ||
message: Request body is required | ||
|
||
# Get 요청의 경우 parameters가 정의되어 있어야함 | ||
operation-parameters-convention: | ||
description: Get Operation might include parameters | ||
given: $.paths[*].get | ||
severity: warn # 파라미터가 없는 Get 요청에 대응 | ||
then: | ||
- field: parameters | ||
function: truthy | ||
message: Parameters are 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 with description, content | ||
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 | ||
|
||
# 각 응답 코드는 descriptioin과 content를 포함해야함 | ||
operation-responsedetail-convention: | ||
description: All Operation response should include description, content | ||
given: $.paths[*][*].responses[*] | ||
severity: error | ||
then: | ||
- field: 'description' | ||
function: truthy | ||
message: Description is required | ||
- field: 'content' | ||
function: truthy | ||
message: Content is required | ||
|
||
# 각 응답 코드는 descriptioin과 content를 포함해야하는데, 401은 content가 없어도 됨 | ||
operation-responsedetail-convention: | ||
description: All Operation response should include description, content | ||
given: $.paths[*][*].responses[*] | ||
severity: off | ||
then: | ||
- field: 'content' | ||
function: truthy | ||
message: Content is not required when response code is 401 |