Skip to content

Commit 171ebd3

Browse files
authored
Merge branch 'master' into errors-details
2 parents d739045 + 6957fde commit 171ebd3

11 files changed

+1682
-1079
lines changed

entrypoint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fs = require('fs');
44
const yaml = require('js-yaml');
55

66
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');
88

99
const SPECTRAL_CONFIG = '.spectral.yaml';
1010
const ISP_RULES_PREFIX = process.env.ISP_RULES_PREFIX || './';

fixtures/disable/openapi.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openapi: '3.0.0'
1+
openapi: "3.0.0"
22
info:
33
version: 1.0.0
44
title: API Fixture
@@ -21,7 +21,7 @@ paths:
2121
tags:
2222
- Test
2323
parameters:
24-
- name: startedUtc
24+
- name: started_utc
2525
in: query
2626
description: Some query param
2727
schema:
@@ -39,5 +39,5 @@ paths:
3939
format: date-time
4040
example: 2020-01-01T12:00:00Z
4141
responses:
42-
'204':
42+
"204":
4343
description: Response description

fixtures/lint/casing-fail.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openapi: '3.0.0'
1+
openapi: "3.0.0"
22
info:
33
version: 1.0.0
44
title: API Fixture
@@ -21,11 +21,11 @@ paths:
2121
tags:
2222
- Test
2323
parameters:
24-
- name: some_query_param
24+
- name: someQueryParam
2525
in: query
2626
description: Some query param
2727
schema:
2828
type: string
2929
responses:
30-
'204':
30+
"204":
3131
description: Response description

fixtures/lint/casing-pass.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openapi: '3.0.0'
1+
openapi: "3.0.0"
22
info:
33
version: 1.0.0
44
title: API Fixture
@@ -21,11 +21,11 @@ paths:
2121
tags:
2222
- Test
2323
parameters:
24-
- name: someQueryParam
24+
- name: some_query_param
2525
in: query
2626
description: Some query param
2727
schema:
2828
type: string
2929
responses:
30-
'204':
30+
"204":
3131
description: Response description

fixtures/lint/casing-properties-fail.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openapi: '3.0.0'
1+
openapi: "3.0.0"
22
info:
33
version: 1.0.0
44
title: API Fixture
@@ -21,13 +21,13 @@ paths:
2121
tags:
2222
- Test
2323
responses:
24-
'200':
24+
"200":
2525
description: Response description
2626
content:
2727
application/json:
2828
schema:
2929
type: object
3030
properties:
31-
foo_bar:
31+
fooBar:
3232
type: string
33-
description: foo_bar property
33+
description: fooBar property

fixtures/lint/casing-properties-pass.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openapi: '3.0.0'
1+
openapi: "3.0.0"
22
info:
33
version: 1.0.0
44
title: API Fixture
@@ -21,7 +21,7 @@ paths:
2121
tags:
2222
- Test
2323
responses:
24-
'200':
24+
"200":
2525
description: Response description
2626
content:
2727
application/json:
@@ -30,6 +30,6 @@ paths:
3030
items:
3131
type: object
3232
properties:
33-
fooBar:
33+
foo_bar:
3434
type: string
35-
description: fooBar property
35+
description: foo_bar property

fixtures/lint/version-pass.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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

isp-functions/noun-deps.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ module.exports = targetValue => {
5959
for (const value of pieces.slice(0, -1)) {
6060
if (value.startsWith('{')) continue;
6161

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+
6266
// Ensure words are plural if later paths exist.
6367
const plural = inflection.pluralize(value);
6468
if (value !== plural) {

isp-rules.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ rules:
8686
field: description
8787
function: truthy
8888
# Resource field casing
89-
properties-lower-camel-case:
89+
properties-lower-snake-case:
9090
severity: error
9191
given: $..properties.*~
9292
then:
9393
function: casing
9494
functionOptions:
95-
type: camel
95+
type: snake
9696
# Don't POST with identifier
9797
post-with-id:
9898
severity: error
@@ -154,15 +154,15 @@ rules:
154154
then:
155155
function: pattern
156156
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:
159159
severity: error
160-
message: "`{{value}}` must follow `lowerCamelCase` notation"
160+
message: '`{{value}}` must follow `snake` notation'
161161
given: "$..parameters[?(@.in == 'query' || @ == 'path')].name"
162162
then:
163163
function: casing
164164
functionOptions:
165-
type: camel
165+
type: snake
166166
# Parameter location constraints
167167
params-location:
168168
severity: error

0 commit comments

Comments
 (0)