-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy path.spectral.yaml
197 lines (178 loc) · 4.8 KB
/
.spectral.yaml
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
193
194
195
196
197
extends: ['spectral:oas']
functions: [debug]
rules:
# OPEN API
alchemy-version-3.1.0:
severity: error
description: 'OpenAPI `openapi` must be set to version 3.1.0.'
given: $
then:
field: openapi
function: pattern
functionOptions:
match: \b3.1.0\b
# INFO
info-description: off
info-contact: off
# SERVERS
alchemy-servers-length:
severity: error
description: Servers must have 1 server object.
given: $.servers
then:
function: length
functionOptions:
min: 1
max: 1
# alchemy-servers-url:
# severity: error
# description: Url must be valid format.
# given: $.servers.*
# then:
# field: url
# function: pattern
# functionOptions:
# match: "https://{network}.g.alchemy.com/v2"
alchemy-servers-networks-supported:
severity: error
description: '"network" property must be one of supported networks.'
given: $.servers[0].variables.network.enum.*
then:
- function: enumeration
functionOptions:
values:
- eth-mainnet
- eth-goerli
- polygon-mainnet
- polygon-mumbai
- arb-mainnet
- arb-goerli
alchemy-servers-network-casing:
severity: error
description: '"network" must be kebab cased and without digits.'
given: $.servers[0].variables.network.enum.*
then:
- function: casing
functionOptions:
type: kebab
disallowDigits: true
alchemy-servers-networks-default:
severity: error
given: $.servers.0.variables.network.default
description: Must have a default network.
then:
function: enumeration
functionOptions:
values:
- eth-mainnet
- polygon-mainnet
- arb-mainnet
# X-README
alchemy-x-readme-id:
severity: warn
given: $.x-readme
message: '{{property}} missing. If creating a new spec, ignore this warning. If updating an existing one, id should be set.'
then:
field: id
function: defined
alchemy-x-readme-id-length:
severity: warn
given: $.x-readme
description: 'Id should have a length of 24.'
then:
field: id
function: length
functionOptions:
min: 24
max: 24
# does not check for order or duplicates
alchemy-x-readme-samples-languages:
severity: warn
given: $.x-readme.samples-languages.*
description: '"x-readme.samples-languages" property must be one of [curl, javascript, python]'
then:
function: enumeration
functionOptions:
values:
- curl
- javascript
- python
# PATHS
alchemy-paths-json-rpc-1-path:
severity: error
given: $.paths
description: '"paths" property must have exactly 1 path.'
then:
function: length
functionOptions:
min: 1
max: 1
alchemy-paths-json-rpc-path:
severity: error
description: '"paths" must have a property "/{apiKey}".'
given: $.paths
then:
- field: '/{apiKey}'
function: defined
# OPERATIONS
operation-description: warn
operation-tags: off
alchemy-operation-json-rpc-post:
severity: error
description: '"/{apiKey}" must just have property post.'
given: $.paths["/{apiKey}"]
then:
- function: length
functionOptions:
min: 1
max: 1
- field: post
function: defined
alchemy-operation-summary:
severity: error
description: 'Operation must have "summary"'
given: $.paths.*.*
then:
- field: summary
function: defined
# already enforced via operation-operationId
# alchemy-operation-operationId:
# severity: error
# description: "Operation must have \"operationId\""
# given: $.paths.*.*
# then:
# - field: summary
# function: defined
alchemy-operation-operationId-casing:
severity: error
message: '{{property}} must be kebab cased and without digits.'
given: $.paths.*.*
then:
- field: operationId
function: casing
functionOptions:
type: kebab
disallowDigits: true
# PARAMETERS
alchemy-json-rpc-auth:
severity: error
description: 'JSON RPC needs to use ApiKey parameter.'
given: $.paths.*.*.parameters[0]
# very important to set to false so ref is not resolved
resolved: false
then:
field: '$ref'
function: 'pattern'
functionOptions:
match: '../components/parameters.yaml#/ApiKey'
# ENUMS
# TODO: this clashes with network enum above - fix this
alchemy-enums-casing:
severity: warn
message: 'Enums must be macro case (uppercase and separated by _).'
given: $..enum.*
then:
function: casing
functionOptions:
type: macro
# TODO: add rule to check response fields are camelCased