-
Notifications
You must be signed in to change notification settings - Fork 78
/
ruleset.yml
192 lines (172 loc) · 5.31 KB
/
ruleset.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
functions:
- ensurePropertiesExample
- ensureAllArraysHaveItemTypes
- ensureSnakeCaseWithDigits
- validateOpIDNaming
rules:
ratelimit-headers:
description: Response must include ratelimit-x headers
message: '{{description}}; missing {{property}}'
severity: error
given: $..responses.*
then:
- field: headers.ratelimit-limit
function: truthy
- field: headers.ratelimit-remaining
function: truthy
- field: headers.ratelimit-reset
function: truthy
properties-must-include-examples:
description: Object properties must include examples
given: $..properties..properties.*
severity: error
message: '{{description}}; {{property}}'
then:
function: ensurePropertiesExample
params-must-include-examples:
description: Parameters must include examples
given: $..parameters.*
severity: error
message: '{{description}}; missing {{property}}'
then:
function: xor
functionOptions:
properties:
- example
- examples
headers-must-include-examples:
description: Headers must include examples
given: $..headers.*
severity: error
message: '{{description}}; missing {{property}}'
then:
function: ensurePropertiesExample
endpoint-must-be-ref:
description: Endpoint must be a $ref
message: '{{description}}; {{property}} incorrect'
severity: error
resolved: false
given: $.paths.*.*
then:
field: $ref
function: truthy
path-must-include-version:
description: Path must include the version
message: '{{description}}; {{property}} incorrect'
severity: error
resolved: false
given: '$.paths[*]~'
then:
function: pattern
functionOptions:
match: '^/v2/.*$'
endpoint-ref-must-be-file:
description: Endpoint must a $ref to a file in resources/
message: '{{description}}; {{value}} incorrect'
severity: error
resolved: false
given: $.paths.*.$ref
then:
function: pattern
functionOptions:
match: "^resources\/.*yml$"
common-responses-unauthorized:
description: Responses should contain common response - 401 (unauthorized)
message: '{{description}}. Missing {{property}}'
severity: error
given: $.paths..responses
then:
field: '401'
function: truthy
common-responses-not-found:
description: Responses should contain common response - 404 (not found)
message: '{{description}}. Missing {{property}}'
severity: error
given: $.paths[?(@property.match(/.*\/{.*}.*/))]..responses
then:
field: '404'
function: truthy
common-responses-too-many-requests:
description: Responses should contain common response - 429 (too many requests)
message: '{{description}}. Missing {{property}}'
severity: error
given: $.paths..responses
then:
field: '429'
function: truthy
common-responses-server-error:
description: Responses should contain common response - 500 (server error)
message: '{{description}}. Missing {{property}}'
severity: error
given: $.paths..responses
then:
field: '500'
function: truthy
array-properties-must-have-items-with-type:
description: Array properties must have an items attribute with a type
given: '$..*.properties[*]'
severity: error
message: '{{error}}'
then:
function: ensureAllArraysHaveItemTypes
array-params-must-have-items-with-type:
description: Array parameters must have an items attribute with a type
given: '$..*.parameters[*]'
severity: error
message: '{{error}}'
then:
function: ensureAllArraysHaveItemTypes
operationid-must-follow-new-naming-conventions:
description: operationIds must follow naming conventions for method
type: style
given: '$.paths[*][*]'
severity: error
message: '{{error}}'
then:
function: validateOpIDNaming
schema-key-must-be-snake-cased:
description: schema key must be snake cased (e.g. snake_case)
type: style
given: "$.components['schemas'].*~"
severity: error
message: '{{error}}'
then:
function: ensureSnakeCaseWithDigits
parameter-key-must-be-snake-cased:
description: parameter key must be snake cased (e.g. snake_case)
type: style
given: "$.components['parameters'].*~"
severity: error
message: '{{error}}'
then:
function: ensureSnakeCaseWithDigits
example-key-must-be-snake-cased:
description: example key must be snake cased (e.g. snake_case)
type: style
given: "$.components['examples'].*~"
severity: error
message: '{{error}}'
then:
function: ensureSnakeCaseWithDigits
response-key-must-be-snake-cased:
description: response key must be snake cased (e.g. snake_case)
type: style
given: "$.components['responses'].*~"
severity: error
message: '{{error}}'
then:
function: ensureSnakeCaseWithDigits
oas3-operation-security-defined:
description: Check operation security is defined
severity: "error"
given: "$.paths.*.*"
then:
field: 'security'
function: truthy
oas3-operation-security-scopes-defined:
description: Check operation security's bearer_auth is defined
severity: "error"
given: "$.paths[*][*]..security.*"
then:
field: 'bearer_auth'
function: truthy