forked from vtex/openapi-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.spectral.yml
140 lines (124 loc) · 4.29 KB
/
.spectral.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
extends: ["spectral:oas"]
rules:
path-params: off
operation-operationId: off
oas3-examples-value-or-externalValue: off
oas3-unused-component: off
info-contact: off
write-email-not-e-mail:
description: Should use email instead of e-mail in descriptions
severity: error
given: "$..*[?(@property === 'description')]"
then:
function: pattern
functionOptions:
notMatch: "\\be-mail\\b"
must-include-operation-summary:
description: Operation summary should be included
severity: error
given: "$.paths.*[?( @property === 'get' || @property === 'put' || @property === 'post' || @property === 'delete' || @property === 'options' || @property === 'head' || @property === 'patch' || @property === 'trace' )]"
then:
- field: "summary"
function: truthy
must-include-response-examples:
description: At least one example should be included for each API response
severity: error
given: "$.paths..responses.*.content.*"
then:
- field: "example"
function: truthy
must-include-response-schemas:
description: Each API response must contain a schema
severity: error
given: "$.paths..responses.*.content.*"
then:
- field: "schema"
function: truthy
no-empty-titles:
description: There can be no empty titles in schemas. Removing this title field from the property will solve this issue.
severity: error
given: "$..[?(@.title=='')]~"
then:
function: pattern
functionOptions:
match: "example"
must-end-field-descriptions-with-period:
description: All field descriptions must end with a period (".").
severity: error
given: "$..*['properties']..['description']"
then:
function: pattern
functionOptions:
match: "^.*[.]$"
summaries-should-be-in-sentence-case:
description: All endpoint summaries should use sentence case (capitalize only the first letter).
severity: warn
given: "$..*[?( @property === 'summary')]"
then:
function: pattern
functionOptions:
match: "^[A-Z][a-z ]*$"
no-empty-descriptions:
description: No empty descriptions allowed.
severity: error
given: "$..*[?(@property === 'description')]"
then:
function: pattern
functionOptions:
match: "^(?!\\s*$).+"
parameters-description:
description: Each parameter must contain a description.
severity: error
given: "$.paths.*.*.parameters[*]"
then:
field: "description"
function: truthy
properties-description:
description: Each request or response body property must contain a description.
severity: error
given: "$..properties.*"
then:
field: "description"
function: truthy
properties-type:
description: Each request or response body property must contain a type.
severity: error
given: "$..properties.*"
then:
field: "type"
function: truthy
items-description:
description: Each request or response body array "items" property must contain a description.
severity: error
given: "$..items"
then:
field: "description"
function: truthy
items-type:
description: Each request or response body array "items" property must contain a type.
severity: error
given: "$..items"
then:
field: "type"
function: truthy
request-body-properties-example:
description: Each request body property must contain an example.
severity: error
given: "$..requestBody..*[?(@.type=='string' || @.type=='integer' || @.type=='boolean')]"
then:
field: "example"
function: truthy
request-body-objects-arrays-example:
description: In the request body, objects and arrays should not contain examples. Only scalar fields should contain examples in the request body.
severity: error
given: "$..requestBody..*[?(@.type=='object' || @.type=='array')]"
then:
field: "example"
function: falsy
response-body-objects-arrays-example:
description: Response body fields should not contain the "example" field. The response example corresponds to the whole schema.
severity: error
given: "$..responses..*[?(@.type=='object' || @.type=='array' || @.type=='integer' || @.type=='boolean' || @.type=='string')]"
then:
field: "example"
function: falsy