diff --git a/.spectral.yaml b/.spectral.yaml new file mode 100644 index 00000000..c69bf5d4 --- /dev/null +++ b/.spectral.yaml @@ -0,0 +1,83 @@ +# Source: https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules +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 + + # 응답이 정의되어 있어야함 + 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