-
Notifications
You must be signed in to change notification settings - Fork 2
/
.spectral.yaml
40 lines (40 loc) · 1.27 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
extends:
- "spectral:oas"
rules:
# ---------------------------------------------------------------------------
# Schema rules
# ---------------------------------------------------------------------------
info-version-semver:
severity: error
recommended: true
message: Specs should follow semantic versioning. {{value}} is not a valid version.
given: $.info.version
then:
function: pattern
functionOptions:
match: "^([0-9]+.[0-9]+.[0-9]+)$"
# ---------------------------------------------------------------------------
# API Rules
# ---------------------------------------------------------------------------
server-url-must-contain-version:
description: Global API version must be present in the path
severity: error
recommended: true
message: "Unversioned server URL detected: {{value}}"
given: "$.servers[*].url"
then:
function: pattern
functionOptions:
match: "\/v[1-9]+\/"
paths-kebab-case:
description: Paths should be kebab-case.
message: "{{property}} should be kebab-case (lower-case and separated with hyphens)"
severity: warn
given: $.paths[*]~
then:
function: pattern
functionOptions:
match: "^(\/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"