-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/ruleset-asyncapi-schema-example-valid…
…ation
- Loading branch information
Showing
16 changed files
with
421 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
lts/* | ||
18.18.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@stoplight/spectral-rulesets", | ||
"version": "1.18.1", | ||
"version": "1.19.1", | ||
"homepage": "https://github.com/stoplightio/spectral", | ||
"bugs": "https://github.com/stoplightio/spectral/issues", | ||
"author": "Stoplight <[email protected]>", | ||
|
@@ -37,7 +37,7 @@ | |
"devDependencies": { | ||
"@stoplight/path": "^1.3.2", | ||
"@stoplight/spectral-parsers": "*", | ||
"@stoplight/spectral-ref-resolver": "*", | ||
"@stoplight/spectral-ref-resolver": "^1.0.4", | ||
"gzip-size": "^6.0.0", | ||
"immer": "^9.0.6", | ||
"terser": "^5.26.0" | ||
|
234 changes: 234 additions & 0 deletions
234
packages/rulesets/src/oas/__tests__/array-items.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
import { DiagnosticSeverity } from '@stoplight/types'; | ||
|
||
import testRule from '../../__tests__/__helpers__/tester'; | ||
|
||
testRule('array-items', [ | ||
{ | ||
name: 'valid case', | ||
document: { | ||
swagger: '2.0', | ||
securityDefinitions: { | ||
apikey: {}, | ||
}, | ||
paths: { | ||
'/path': { | ||
get: { | ||
security: [ | ||
{ | ||
apikey: [], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'array items sibling is present in a oas2 document', | ||
document: { | ||
swagger: '2.0', | ||
securityDefinitions: { | ||
apikey: {}, | ||
$ref: '#/securityDefinitions/apikey', | ||
}, | ||
paths: { | ||
$ref: '#/securityDefinitions/apikey', | ||
'/path': { | ||
get: { | ||
'200': { | ||
schema: { | ||
type: 'array', | ||
items: {}, | ||
}, | ||
}, | ||
}, | ||
post: { | ||
'201': { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
items: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'array items sibling is present in oas3 document', | ||
document: { | ||
$ref: '#/', | ||
responses: { | ||
200: { | ||
type: 'array', | ||
items: {}, | ||
}, | ||
201: { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
items: {}, | ||
}, | ||
}, | ||
}, | ||
openapi: '3.0.0', | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'array items sibling is present in oas3.1 document', | ||
document: { | ||
openapi: '3.1.0', | ||
paths: { | ||
'/path': { | ||
get: { | ||
responses: { | ||
'200': { | ||
type: 'array', | ||
items: {}, | ||
}, | ||
}, | ||
}, | ||
post: { | ||
responses: { | ||
'201': { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
items: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'array items sibling is missing in a oas2 document', | ||
document: { | ||
swagger: '2.0', | ||
securityDefinitions: { | ||
apikey: {}, | ||
$ref: '#/securityDefinitions/apikey', | ||
}, | ||
paths: { | ||
$ref: '#/securityDefinitions/apikey', | ||
'/path': { | ||
get: { | ||
'200': { | ||
schema: { | ||
type: 'array', | ||
}, | ||
}, | ||
}, | ||
post: { | ||
'201': { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
code: 'array-items', | ||
message: 'Schemas with "type: array", require a sibling "items" field', | ||
path: ['paths', '/path', 'get', '200', 'schema'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
{ | ||
code: 'array-items', | ||
message: 'Schemas with "type: array", require a sibling "items" field', | ||
path: ['paths', '/path', 'post', '201', 'items'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'array items sibling is missing in oas3 document', | ||
document: { | ||
$ref: '#/', | ||
responses: { | ||
200: { | ||
type: 'array', | ||
}, | ||
201: { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
}, | ||
}, | ||
}, | ||
openapi: '3.0.0', | ||
}, | ||
errors: [ | ||
{ | ||
code: 'array-items', | ||
message: 'Schemas with "type: array", require a sibling "items" field', | ||
path: ['responses', '200'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
{ | ||
code: 'array-items', | ||
message: 'Schemas with "type: array", require a sibling "items" field', | ||
path: ['responses', '201', 'items'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'array items sibling is missing in oas3.1 document', | ||
document: { | ||
openapi: '3.1.0', | ||
paths: { | ||
'/path': { | ||
get: { | ||
responses: { | ||
'200': { | ||
type: 'array', | ||
}, | ||
}, | ||
}, | ||
post: { | ||
responses: { | ||
'201': { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
code: 'array-items', | ||
message: 'Schemas with "type: array", require a sibling "items" field', | ||
path: ['paths', '/path', 'get', 'responses', '200'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
{ | ||
code: 'array-items', | ||
message: 'Schemas with "type: array", require a sibling "items" field', | ||
path: ['paths', '/path', 'post', 'responses', '201', 'items'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
]); |
Oops, something went wrong.