Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into fix/core/bump-nimma
- Loading branch information
Showing
12 changed files
with
562 additions
and
66 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
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
197 changes: 197 additions & 0 deletions
197
packages/rulesets/src/asyncapi/__tests__/asyncapi-message-examples.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,197 @@ | ||
import { DiagnosticSeverity } from '@stoplight/types'; | ||
import testRule from './__helpers__/tester'; | ||
|
||
testRule('asyncapi-message-examples', [ | ||
{ | ||
name: 'valid case', | ||
document: { | ||
asyncapi: '2.0.0', | ||
channels: { | ||
someChannel: { | ||
publish: { | ||
message: { | ||
payload: { | ||
type: 'string', | ||
}, | ||
headers: { | ||
type: 'object', | ||
}, | ||
examples: [ | ||
{ | ||
payload: 'foobar', | ||
headers: { | ||
someKey: 'someValue', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'invalid case', | ||
document: { | ||
asyncapi: '2.0.0', | ||
channels: { | ||
someChannel: { | ||
publish: { | ||
message: { | ||
payload: { | ||
type: 'string', | ||
}, | ||
headers: { | ||
type: 'object', | ||
}, | ||
examples: [ | ||
{ | ||
payload: 2137, | ||
headers: { | ||
someKey: 'someValue', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: '"payload" property type must be string', | ||
path: ['channels', 'someChannel', 'publish', 'message', 'examples', '0', 'payload'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'invalid case (oneOf case)', | ||
document: { | ||
asyncapi: '2.0.0', | ||
channels: { | ||
someChannel: { | ||
publish: { | ||
message: { | ||
oneOf: [ | ||
{ | ||
payload: { | ||
type: 'string', | ||
}, | ||
headers: { | ||
type: 'object', | ||
}, | ||
examples: [ | ||
{ | ||
payload: 2137, | ||
headers: { | ||
someKey: 'someValue', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: '"payload" property type must be string', | ||
path: ['channels', 'someChannel', 'publish', 'message', 'oneOf', '0', 'examples', '0', 'payload'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'invalid case (inside components.messages)', | ||
document: { | ||
asyncapi: '2.0.0', | ||
components: { | ||
messages: { | ||
someMessage: { | ||
payload: { | ||
type: 'string', | ||
}, | ||
headers: { | ||
type: 'object', | ||
}, | ||
examples: [ | ||
{ | ||
payload: 2137, | ||
headers: { | ||
someKey: 'someValue', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: '"payload" property type must be string', | ||
path: ['components', 'messages', 'someMessage', 'examples', '0', 'payload'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'invalid case (with multiple errors)', | ||
document: { | ||
asyncapi: '2.0.0', | ||
components: { | ||
messages: { | ||
someMessage: { | ||
payload: { | ||
type: 'object', | ||
required: ['key1', 'key2'], | ||
properties: { | ||
key1: { | ||
type: 'string', | ||
}, | ||
key2: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
headers: { | ||
type: 'object', | ||
}, | ||
examples: [ | ||
{ | ||
payload: { | ||
key1: 2137, | ||
}, | ||
headers: 'someValue', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: '"payload" property must have required property "key2"', | ||
path: ['components', 'messages', 'someMessage', 'examples', '0', 'payload'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
{ | ||
message: '"key1" property type must be string', | ||
path: ['components', 'messages', 'someMessage', 'examples', '0', 'payload', 'key1'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
{ | ||
message: '"headers" property type must be object', | ||
path: ['components', 'messages', 'someMessage', 'examples', '0', 'headers'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
]); |
Oops, something went wrong.