File tree 11 files changed +1682
-1079
lines changed
11 files changed +1682
-1079
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const fs = require('fs');
4
4
const yaml = require ( 'js-yaml' ) ;
5
5
6
6
const { Spectral, isOpenApiv3 } = require ( '@stoplight/spectral' ) ;
7
- const { stylish } = require ( '@stoplight/spectral/dist/formatters/stylish' ) ;
7
+ const { stylish } = require ( '@stoplight/spectral/dist/cli/ formatters/stylish' ) ;
8
8
9
9
const SPECTRAL_CONFIG = '.spectral.yaml' ;
10
10
const ISP_RULES_PREFIX = process . env . ISP_RULES_PREFIX || './' ;
Original file line number Diff line number Diff line change 1
- openapi : ' 3.0.0'
1
+ openapi : " 3.0.0"
2
2
info :
3
3
version : 1.0.0
4
4
title : API Fixture
21
21
tags :
22
22
- Test
23
23
parameters :
24
- - name : startedUtc
24
+ - name : started_utc
25
25
in : query
26
26
description : Some query param
27
27
schema :
39
39
format : date-time
40
40
example : 2020-01-01T12:00:00Z
41
41
responses :
42
- ' 204 ' :
42
+ " 204 " :
43
43
description : Response description
Original file line number Diff line number Diff line change 1
- openapi : ' 3.0.0'
1
+ openapi : " 3.0.0"
2
2
info :
3
3
version : 1.0.0
4
4
title : API Fixture
@@ -21,11 +21,11 @@ paths:
21
21
tags :
22
22
- Test
23
23
parameters :
24
- - name : some_query_param
24
+ - name : someQueryParam
25
25
in : query
26
26
description : Some query param
27
27
schema :
28
28
type : string
29
29
responses :
30
- ' 204 ' :
30
+ " 204 " :
31
31
description : Response description
Original file line number Diff line number Diff line change 1
- openapi : ' 3.0.0'
1
+ openapi : " 3.0.0"
2
2
info :
3
3
version : 1.0.0
4
4
title : API Fixture
@@ -21,11 +21,11 @@ paths:
21
21
tags :
22
22
- Test
23
23
parameters :
24
- - name : someQueryParam
24
+ - name : some_query_param
25
25
in : query
26
26
description : Some query param
27
27
schema :
28
28
type : string
29
29
responses :
30
- ' 204 ' :
30
+ " 204 " :
31
31
description : Response description
Original file line number Diff line number Diff line change 1
- openapi : ' 3.0.0'
1
+ openapi : " 3.0.0"
2
2
info :
3
3
version : 1.0.0
4
4
title : API Fixture
@@ -21,13 +21,13 @@ paths:
21
21
tags :
22
22
- Test
23
23
responses :
24
- ' 200 ' :
24
+ " 200 " :
25
25
description : Response description
26
26
content :
27
27
application/json :
28
28
schema :
29
29
type : object
30
30
properties :
31
- foo_bar :
31
+ fooBar :
32
32
type : string
33
- description : foo_bar property
33
+ description : fooBar property
Original file line number Diff line number Diff line change 1
- openapi : ' 3.0.0'
1
+ openapi : " 3.0.0"
2
2
info :
3
3
version : 1.0.0
4
4
title : API Fixture
21
21
tags :
22
22
- Test
23
23
responses :
24
- ' 200 ' :
24
+ " 200 " :
25
25
description : Response description
26
26
content :
27
27
application/json :
30
30
items :
31
31
type : object
32
32
properties :
33
- fooBar :
33
+ foo_bar :
34
34
type : string
35
- description : fooBar property
35
+ description : foo_bar property
Original file line number Diff line number Diff line change
1
+ openapi : " 3.0.0"
2
+ info :
3
+ version : 1.0.0
4
+ title : API Fixture
5
+ description : API fixture description
6
+ license :
7
+ name : Apache2
8
+ contact :
9
+
10
+ servers :
11
+ - url : https://api.example.com/v1
12
+ tags :
13
+ - name : Test
14
+ description : Test tag
15
+ paths :
16
+ /v2/tests :
17
+ get :
18
+ summary : Test operation
19
+ description : Test operation description
20
+ operationId : test
21
+ tags :
22
+ - Test
23
+ responses :
24
+ " 204 " :
25
+ description : Response description
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ module.exports = targetValue => {
59
59
for ( const value of pieces . slice ( 0 , - 1 ) ) {
60
60
if ( value . startsWith ( '{' ) ) continue ;
61
61
62
+ // our api version is in the url as a resource
63
+ // this does not need to be plural
64
+ if ( value . match ( / v [ 0 - 9 ] + / ) ) continue ;
65
+
62
66
// Ensure words are plural if later paths exist.
63
67
const plural = inflection . pluralize ( value ) ;
64
68
if ( value !== plural ) {
Original file line number Diff line number Diff line change @@ -86,13 +86,13 @@ rules:
86
86
field : description
87
87
function : truthy
88
88
# Resource field casing
89
- properties-lower-camel -case :
89
+ properties-lower-snake -case :
90
90
severity : error
91
91
given : $..properties.*~
92
92
then :
93
93
function : casing
94
94
functionOptions :
95
- type : camel
95
+ type : snake
96
96
# Don't POST with identifier
97
97
post-with-id :
98
98
severity : error
@@ -154,15 +154,15 @@ rules:
154
154
then :
155
155
function : pattern
156
156
functionOptions :
157
- match : " /^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/"
158
- params-lower-camel -case :
157
+ match : ' /^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/'
158
+ params-lower-snake -case :
159
159
severity : error
160
- message : " `{{value}}` must follow `lowerCamelCase ` notation"
160
+ message : ' `{{value}}` must follow `snake ` notation'
161
161
given : " $..parameters[?(@.in == 'query' || @ == 'path')].name"
162
162
then :
163
163
function : casing
164
164
functionOptions :
165
- type : camel
165
+ type : snake
166
166
# Parameter location constraints
167
167
params-location :
168
168
severity : error
You can’t perform that action at this time.
0 commit comments