Skip to content

Commit 23819e7

Browse files
committed
errors->problem+json
1 parent 9b45327 commit 23819e7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

isp-rules.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
formats:
2-
- 'oas3'
2+
- "oas3"
33
extends: spectral:oas
44
functionsDir: isp-functions
55
functions:
@@ -17,15 +17,15 @@ rules:
1717
# Use JSON as much as possible
1818
json-responses:
1919
severity: error
20-
message: '{{description}}: {{error}}'
20+
message: "{{description}}: {{error}}"
2121
given: $..responses.[?(@property == '200' || @ == '201' || @ == '202' || @ == '400' || @ == '401' || @ == '403' || @ == '404' || @ == '422' || @ == '500')].content
2222
then:
2323
function: contains
2424
functionOptions:
25-
match: 'json'
25+
match: "json"
2626
patch-request-content-type:
2727
severity: error
28-
description: '`PATCH` requests cannot use `application/json`'
28+
description: "`PATCH` requests cannot use `application/json`"
2929
given: $.paths.*.[?(@property == 'patch')].requestBody.content[?(@property == 'application/json')]^
3030
then:
3131
function: falsy
@@ -47,7 +47,7 @@ rules:
4747
then:
4848
function: pattern
4949
functionOptions:
50-
match: 'localhost|/v[0-9]+$'
50+
match: "localhost|/v[0-9]+$"
5151
# Use ISO 8601 for dates
5252
iso8601:
5353
severity: warn
@@ -132,19 +132,19 @@ rules:
132132
description: Delete should return an HTTP 204
133133
given: $.paths.*[?(@property === 'delete')].responses
134134
then:
135-
field: '204'
135+
field: "204"
136136
function: truthy
137137
# Errors must include a `detail` field
138138
error-detail:
139139
severity: error
140-
description: Errors must be JSON and include a "detail" field
140+
description: Errors must be problem+JSON and include a "detail" field
141141
given: $..responses.[?(@property.toString().startsWith("4") || @property.toString() === "500")]
142142
then:
143143
- field: content
144144
function: truthy
145-
- field: content.application/json.schema
145+
- field: content.application/problem+json.schema
146146
function: truthy
147-
- field: content.application/json.schema.properties.detail
147+
- field: content.application/problem+json.schema.properties.detail
148148
function: truthy
149149
# Header & parameter casing
150150
headers-hyphenated-pascal-case:
@@ -154,10 +154,10 @@ rules:
154154
then:
155155
function: pattern
156156
functionOptions:
157-
match: '/^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/'
157+
match: "/^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/"
158158
params-lower-camel-case:
159159
severity: error
160-
message: '`{{value}}` must follow `lowerCamelCase` notation'
160+
message: "`{{value}}` must follow `lowerCamelCase` notation"
161161
given: "$..parameters[?(@.in == 'query' || @ == 'path')].name"
162162
then:
163163
function: casing

0 commit comments

Comments
 (0)