diff --git a/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2SchemaValidation.test.ts b/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2SchemaValidation.test.ts index db2ef4255..e4538dc5c 100644 --- a/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2SchemaValidation.test.ts +++ b/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2SchemaValidation.test.ts @@ -7,19 +7,19 @@ function runPayloadValidation(targetVal: any, opts: { type: 'examples' | 'defaul describe('asyncApi2SchemaValidation', () => { test('validates examples', () => { const payload = { - type: 'string', - examples: [17, 'one', 13], + type: 'object', + examples: [17, {}, 13, 'string-is-always-accepted'], }; const results = runPayloadValidation(payload, { type: 'examples' }); expect(results).toEqual([ { - message: '"0" property type must be string', + message: '"0" property type must be object', path: ['examples', 0], }, { - message: '"2" property type must be string', + message: '"2" property type must be object', path: ['examples', 2], }, ]); diff --git a/packages/rulesets/src/asyncapi/functions/asyncApi2SchemaValidation.ts b/packages/rulesets/src/asyncapi/functions/asyncApi2SchemaValidation.ts index dc36f0692..3fa907b03 100644 --- a/packages/rulesets/src/asyncapi/functions/asyncApi2SchemaValidation.ts +++ b/packages/rulesets/src/asyncapi/functions/asyncApi2SchemaValidation.ts @@ -67,7 +67,7 @@ export default createRulesetFunction( }, ); - if (Array.isArray(result)) { + if (Array.isArray(result) && typeof relevantItem.value !== 'string') { results.push(...result); } }