Skip to content

Commit 7becb29

Browse files
committed
DMP-5275 (Dev only) Spectral setup + initial warning reductions darts-api
Added spectral config
1 parent cafdfc3 commit 7becb29

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

.spectral.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,83 @@ extends: [ "spectral:oas" ]
22
rules:
33
oas3-valid-media-example: off
44
oas3-valid-schema-example: off
5+
strings-need-bounds:
6+
description: Strings must be bounded unless they already use format/enum/pattern
7+
given:
8+
- "$.components.schemas.*"
9+
- "$.paths.*.*.parameters[*].schema"
10+
- "$.paths.*.*.requestBody.content.*.schema"
11+
- "$.paths.*.*.responses.*.content.*.schema"
12+
then:
13+
function: schema
14+
functionOptions:
15+
schema:
16+
if:
17+
properties: { type: { const: string } }
18+
required: [ type ]
19+
then:
20+
anyOf:
21+
- required: [ maxLength ]
22+
- required: [ enum ]
23+
- required: [ pattern ]
24+
- required: [ format ]
25+
severity: warn
26+
27+
arrays-need-maxitems:
28+
given:
29+
- "$.components.schemas.*"
30+
- "$.paths.*.*.parameters[*].schema"
31+
- "$.paths.*.*.requestBody.content.*.schema"
32+
- "$.paths.*.*.responses.*.content.*.schema"
33+
then:
34+
function: schema
35+
functionOptions:
36+
schema:
37+
if:
38+
properties: { type: { const: array } }
39+
required: [ type ]
40+
then:
41+
required: [ maxItems ]
42+
severity: warn
43+
44+
path-string-params-need-format-or-pattern:
45+
given:
46+
- "$.paths.*.*.parameters[?(@.in=='path')].schema"
47+
then:
48+
function: schema
49+
functionOptions:
50+
schema:
51+
if:
52+
properties: { type: { const: string } }
53+
required: [ type ]
54+
then:
55+
anyOf:
56+
- required: [ format ]
57+
- required: [ pattern ]
58+
severity: warn
59+
60+
param-id-needs-format-or-pattern:
61+
given:
62+
- "$.paths.*.*.parameters[?(@.name=='id')].schema"
63+
then:
64+
function: schema
65+
functionOptions:
66+
schema:
67+
anyOf:
68+
- required: [ format ]
69+
- required: [ pattern ]
70+
severity: warn
71+
72+
schema-id-prop-needs-format-or-pattern:
73+
given:
74+
- "$.components.schemas.*.properties.id"
75+
- "$.paths.*.*.requestBody.content.*.schema.properties.id"
76+
then:
77+
function: schema
78+
functionOptions:
79+
schema:
80+
anyOf:
81+
- required: [ format ]
82+
- required: [ pattern ]
83+
severity: warn
84+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ This repo contains overrides for the default dev environment configuration, cont
398398
This repository uses spectral to validate OpenAPI specifications. To validate the OpenAPI specification:
399399
400400
```bash
401-
spectral lint "src/main/resources/openapi/**/*.{yml,yaml}"
401+
spectral lint --verbose "src/main/resources/openapi/**/*.{yml,yaml}"
402402
```
403403
404404
Documentation: https://stoplight.io/open-source/spectral

0 commit comments

Comments
 (0)