30
30
then :
31
31
function : pattern
32
32
functionOptions :
33
- match : " ^([0 -9]+.[0 -9]+ .[0-9 ]+)$ "
33
+ match : ' ^(0|[1-9]\d*)\.(0|[1 -9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1 -9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\ .[0-9a-zA-Z- ]+)*))?$ '
34
34
pathsSummary :
35
35
description : There needs to be a summary field for every method.
36
36
message : " There needs to be a summary property for every method."
@@ -63,11 +63,12 @@ rules:
63
63
componentsRequestBodiesExists :
64
64
description : There should be a requestBodies section within components.
65
65
message : " Components is missing the '{{property}}' section"
66
- given : " $.components "
66
+ given : " $.paths.[*][put, patch, post].requestBody.ref "
67
67
severity : warn
68
68
then :
69
- - field : " requestBodies"
70
- function : truthy
69
+ function : pattern
70
+ functionOptions :
71
+ match : " #\/ components\/ requestBodies\/ "
71
72
camelCaseOperationId :
72
73
description : All operationIds should be written in camelCase.
73
74
message : " '{{value}}' needs to be written in camelCase."
@@ -78,21 +79,41 @@ rules:
78
79
function : casing
79
80
functionOptions :
80
81
type : camel
81
- camelCaseParameterName :
82
- description : All parameter names should be written in camelCase.
82
+ camelCaseComponentNames :
83
+ description : All component names should be written in camelCase.
84
+ message : " '{{value}}' needs to be written in camelCase."
85
+ type : style
86
+ given : " $.components..names"
87
+ severity : warn
88
+ then :
89
+ function : casing
90
+ functionOptions :
91
+ type : camel
92
+ camelCaseComponents :
93
+ description : All components (schemas, parameters, etc) should be named in camelCase.
83
94
message : " '{{value}}' needs to be written in camelCase."
84
95
type : style
85
- given : " $.components.parameters.*.name "
96
+ given : " $.components.[callbacks,schemas, parameters,examples,requestBodies,responses][*]~ "
86
97
severity : warn
87
98
then :
88
99
function : casing
89
100
functionOptions :
90
101
type : camel
102
+ sentenceCaseDescriptions :
103
+ description : Descriptions should be written in a normal sentence case.
104
+ message : " '{{value}}' needs to be written in sentence case."
105
+ type : style
106
+ given : " $.*.[paths,schemas,securitySchemes]..description"
107
+ severity : warn
108
+ then :
109
+ function : pattern
110
+ functionOptions :
111
+ match : " (^[A-Z]|(?<=[.?!]))*[A-Z][-_`)(A-Za-z0-9,;'\"\\ s]*[.?!]"
91
112
macroCaseEnum :
92
113
description : Enums should be in MACRO case.
93
114
message : " Enum value '{{value}}' should be written in MACRO case"
94
115
type : style
95
- given : " $.components.*.* .enum.[*]"
116
+ given : " $.components..enum.[*]"
96
117
severity : warn
97
118
then :
98
119
function : casing
@@ -101,63 +122,64 @@ rules:
101
122
badRequestError :
102
123
description : " Responses should define a HTTP 400 Bad Request error"
103
124
message : " Responses should define a 400 Bad Request Error."
104
- given : " $.paths.[*][*] .responses"
125
+ given : " $.*. paths..responses"
105
126
severity : warn
106
127
then :
107
128
field : " 400"
108
129
function : truthy
109
130
unauthorizedError :
110
131
description : " Resources must declare a response for a HTTP 401 Unauthorized error"
111
132
message : " Responses should define a 401 Unauthorized Error."
112
- given : " $.paths.[*][*] .responses"
133
+ given : " $.*. paths..responses"
113
134
severity : warn
114
135
then :
115
136
field : " 401"
116
137
function : truthy
117
138
forbiddenError :
118
139
description : " Resources must declare a response for a HTTP 403 Forbidden error"
119
140
message : " Responses should define a 403 Forbidden Error."
120
- given : " $.paths.[*][*] .responses"
141
+ given : " $.*. paths..responses"
121
142
severity : warn
122
143
then :
123
144
field : " 403"
124
145
function : truthy
125
146
notFoundError :
126
147
description : " Resources must declare a response for a HTTP 404 Not Found error"
127
148
message : " Responses should define a 404 Not Found Error."
128
- given : " $.paths.[*][get, put, patch, delete].responses"
149
+ given : " $.*. paths.[*][get, put, patch, delete].responses"
129
150
severity : warn
130
151
then :
131
152
field : " 404"
132
153
function : truthy
133
154
methodNotAllowedError :
134
155
description : " Resources must declare a response for a HTTP 405 Method Not Allowed error"
135
156
message : " Responses should define a 405 Method Not Allowed Error."
136
- given : " $.paths.[*][*] .responses"
157
+ given : " $.*. paths..responses"
137
158
severity : warn
138
159
then :
139
160
field : " 405"
140
161
function : truthy
141
162
tooManyRequestsError :
142
163
description : " Resources must declare a response for a HTTP 429 Too Many Requests error"
143
164
message : " Responses should define a 429 Too Many Requests Error."
144
- given : " $.paths.[*][*] .responses"
165
+ given : " $.*. paths..responses"
145
166
severity : warn
146
167
then :
147
168
field : " 429"
148
169
function : truthy
149
170
internalServerError :
150
171
description : " Resources must declare a response for a HTTP 500 Internal Server error"
151
- message : " Responses should define a 500 Internal Server Error."
152
- given : " $.paths.[*][*] .responses"
172
+ message : " Responses should define either a 500 or 5XX Internal Server Error. Note that 5XX must be capitalized ."
173
+ given : " $.*. paths..responses"
153
174
severity : warn
154
175
then :
155
- field : " 500"
156
- function : truthy
176
+ function : pattern
177
+ functionOptions :
178
+ match : " (^[500|5XX]$"
157
179
globallyDefinedResponses :
158
180
description : " Responses should be defined globally and referenced elsewhere."
159
181
message : " All responses should be defined globally and only referenced everywhere else."
160
- given : " $.paths.[*][*] .responses.*[*] "
182
+ given : " $.*. paths..responses"
161
183
resolved : false
162
184
severity : error
163
185
then :
@@ -166,7 +188,7 @@ rules:
166
188
globallyDefinedRequestBodies :
167
189
description : " RequestBodies should be defined globally and referenced elsewhere."
168
190
message : " Every requestBody should be defined globally and only referenced everywhere else."
169
- given : " $.paths.[*][* ].requestBody[*]"
191
+ given : " $.paths.[*][post, put, patch ].requestBody[*]"
170
192
resolved : false
171
193
severity : error
172
194
then :
0 commit comments