Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function asyncApi2MessageExamplesParserRule(parser: Parser): RuleDefiniti
recommended: true,
given: [
// messages
'$.channels.*.[publish,subscribe][?(@property === \'message\' && @.schemaFormat !== void 0)]',
'$.channels.*.[publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat !== void 0)]',
'$.channels.*.[publish,subscribe].message.oneOf[?(!@null && @.schemaFormat !== void 0)]',
'$.components.channels.*.[publish,subscribe].message[?(@property === \'message\' && @.schemaFormat !== void 0)]',
'$.components.channels.*.[publish,subscribe].message[?(@property === \'message\' && !@null && @.schemaFormat !== void 0)]',
'$.components.channels.*.[publish,subscribe].message.oneOf[?(!@null && @.schemaFormat !== void 0)]',
'$.components.messages[?(!@null && @.schemaFormat !== void 0)]',
// message traits
Expand Down
16 changes: 8 additions & 8 deletions packages/parser/src/ruleset/v2/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export const v2CoreRuleset = {
recommended: true,
given: [
// messages
'$.channels.*.[publish,subscribe][?(@property === \'message\' && @.schemaFormat === void 0)]',
'$.channels.*.[publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat === void 0)]',
'$.channels.*.[publish,subscribe].message.oneOf[?(!@null && @.schemaFormat === void 0)]',
'$.components.channels.*.[publish,subscribe][?(@property === \'message\' && @.schemaFormat === void 0)]',
'$.components.channels.*.[publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat === void 0)]',
'$.components.channels.*.[publish,subscribe].message.oneOf[?(!@null && @.schemaFormat === void 0)]',
'$.components.messages[?(!@null && @.schemaFormat === void 0)]',
// message traits
Expand Down Expand Up @@ -201,9 +201,9 @@ export const v2SchemasRuleset = (parser: Parser) => {
severity: 'error',
recommended: true,
given: [
'$.channels[*][publish,subscribe][?(@property === \'message\' && @.schemaFormat === void 0)].payload.default^',
'$.channels[*][publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat === void 0)].payload.default^',
'$.channels.*.parameters.*.schema.default^',
'$.components.channels[*][publish,subscribe][?(@property === \'message\' && @.schemaFormat === void 0)].payload.default^',
'$.components.channels[*][publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat === void 0)].payload.default^',
'$.components.channels.*.parameters.*.schema.default^',
'$.components.schemas.*.default^',
'$.components.parameters.*.schema.default^',
Expand All @@ -223,9 +223,9 @@ export const v2SchemasRuleset = (parser: Parser) => {
severity: 'error',
recommended: true,
given: [
'$.channels[*][publish,subscribe][?(@property === \'message\' && @.schemaFormat === void 0)].payload.examples^',
'$.channels[*][publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat === void 0)].payload.examples^',
'$.channels.*.parameters.*.schema.examples^',
'$.components.channels[*][publish,subscribe][?(@property === \'message\' && @.schemaFormat === void 0)].payload.examples^',
'$.components.channels[*][publish,subscribe][?(@property === \'message\' && !@null && @.schemaFormat === void 0)].payload.examples^',
'$.components.channels.*.parameters.*.schema.examples^',
'$.components.schemas.*.examples^',
'$.components.parameters.*.schema.examples^',
Expand Down Expand Up @@ -338,9 +338,9 @@ export const v2RecommendedRuleset = {
recommended: true,
formats: AsyncAPIFormats.filterByMajorVersions(['2']).excludeByVersions(['2.0.0', '2.1.0', '2.2.0', '2.3.0']).formats(), // message.messageId is available starting from v2.4.
given: [
'$.channels.*.[publish,subscribe][?(@property === "message" && @.oneOf == void 0)]',
'$.channels.*.[publish,subscribe][?(@property === "message" && !@null && @.oneOf == void 0)]',
'$.channels.*.[publish,subscribe].message.oneOf.*',
'$.components.channels.*.[publish,subscribe][?(@property === "message" && @.oneOf == void 0)]',
'$.components.channels.*.[publish,subscribe][?(@property === "message" && !@null && @.oneOf == void 0)]',
'$.components.channels.*.[publish,subscribe].message.oneOf.*',
'$.components.messages.*',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,37 @@ testRule('asyncapi2-message-examples', [
},
],
},

{
name: 'valid case (payload property named "message" with null value in example)',
document: {
asyncapi: '2.6.0',
channels: {
someChannel: {
publish: {
message: {
payload: {
type: 'object',
required: ['message'],
properties: {
message: {
type: ['string', 'null'],
maxLength: 50,
},
},
},
examples: [
{
payload: {
message: null,
},
},
],
},
},
},
},
},
errors: [],
},
]);
Loading