1
+ extends :
2
+ - spectral:oas
3
+ rules :
4
+ # API 버전 규칙 : v로 시작하고 숫자와 점으로 이루어져야 함
5
+ api-version-convention :
6
+ description : API version should follow the convention
7
+ given : $.info.version
8
+ severity : error
9
+ then :
10
+ function : pattern
11
+ functionOptions :
12
+ match : " ^v[0-9\\ .]+$"
13
+ message : API version should follow the convention v1, v2.1, v3.0.1, etc.
14
+
15
+ # 모든 엔드포인트는 tags를 포함해야 함
16
+ operation-tags-convention :
17
+ description : All Operation should include tags
18
+ given : $.paths[*][*]
19
+ severity : error
20
+ then :
21
+ - field : tags
22
+ function : truthy
23
+ message : Tags are required
24
+
25
+ # 모든 엔드포인트는 operationId를 포함해야 함 (.WithName 으로 지정)
26
+ operation-operationid-convention :
27
+ description : All Operation should include operationId
28
+ given : $.paths[*][*]
29
+ severity : error
30
+ then :
31
+ - field : operationId
32
+ function : truthy
33
+ message : OperationId is required
34
+
35
+ # 모든 엔드포인트는 summary와 description을 포함해야 함
36
+ operation-summary-description-convention :
37
+ description : All Operation should include summary and description
38
+ given : $.paths[*][*]
39
+ severity : error
40
+ then :
41
+ - field : ' summary'
42
+ function : truthy
43
+ message : Summary is required
44
+ - field : ' description'
45
+ function : truthy
46
+ message : Description is required
47
+
48
+ # Post 요청의 경우 requestbody가 정의되어 있어야함
49
+ operation-request-convention :
50
+ description : Post Operation should include request body
51
+ given : $.paths[*].post
52
+ severity : error
53
+ then :
54
+ - field : requestBody
55
+ function : truthy
56
+ message : Request body is required
57
+
58
+ # Get 요청의 경우 parameters가 정의되어 있어야함
59
+ operation-parameters-convention :
60
+ description : Get Operation might include parameters
61
+ given : $.paths[*].get
62
+ severity : warn # 파라미터가 없는 Get 요청에 대응
63
+ then :
64
+ - field : parameters
65
+ function : truthy
66
+ message : Parameters are required
67
+
68
+ # 응답이 정의되어 있어야함
69
+ operation-response-convention :
70
+ description : All Operation should include response
71
+ given : $.paths[*][*]
72
+ severity : error
73
+ then :
74
+ - field : responses
75
+ function : truthy
76
+ message : Responses are required
77
+
78
+ # 응답 코드 규칙 : 200, 401, 500 응답 코드가 있어야 함
79
+ operation-responsecode-convention :
80
+ description : All Operation response should include 200, 401, 500 with description, content
81
+ given : $.paths[*][*].responses
82
+ severity : error
83
+ then :
84
+ - field : ' 200'
85
+ function : truthy
86
+ message : Response 200 is required
87
+ - field : ' 401'
88
+ function : truthy
89
+ message : Response 401 is required
90
+ - field : ' 500'
91
+ function : truthy
92
+ message : Response 500 is required
93
+
94
+ # 각 응답 코드는 descriptioin과 content를 포함해야함
95
+ operation-responsedetail-convention :
96
+ description : All Operation response should include description, content
97
+ given : $.paths[*][*].responses[*]
98
+ severity : error
99
+ then :
100
+ - field : ' description'
101
+ function : truthy
102
+ message : Description is required
103
+ - field : ' content'
104
+ function : truthy
105
+ message : Content is required
106
+
107
+ # 각 응답 코드는 descriptioin과 content를 포함해야하는데, 401은 content가 없어도 됨
108
+ operation-responsedetail-convention :
109
+ description : All Operation response should include description, content
110
+ given : $.paths[*][*].responses[*]
111
+ severity : off
112
+ then :
113
+ - field : ' content'
114
+ function : truthy
115
+ message : Content is not required when response code is 401
0 commit comments