diff --git a/src/custom-operations/apply-traits.ts b/src/custom-operations/apply-traits.ts index 6d99453ff..1c2ff7ef0 100644 --- a/src/custom-operations/apply-traits.ts +++ b/src/custom-operations/apply-traits.ts @@ -51,11 +51,9 @@ function applyTraitsToObjectV2(value: Record) { const v3TraitPaths = [ // operations '$.operations.*', - '$.operations.*.channel.*', '$.operations.*.channel.messages.*', '$.operations.*.messages.*', '$.components.operations.*', - '$.components.operations.*.channel.*', '$.components.operations.*.channel.messages.*', '$.components.operations.*.messages.*', // Channels diff --git a/test/validate.spec.ts b/test/validate.spec.ts index 6a3458518..60b85730a 100644 --- a/test/validate.spec.ts +++ b/test/validate.spec.ts @@ -51,4 +51,47 @@ describe('validate()', function() { expect(hasErrorDiagnostic(diagnostics)).toEqual(false); expect(hasWarningDiagnostic(diagnostics)).toEqual(true); }); + + // See https://github.com/asyncapi/parser-js/issues/996 + it('user case - null channel address should not make operation traits appliance fail', async function() { + const documentRaw = { + asyncapi: '3.0.0', + info: { + title: 'Nexus Server API', + version: '1.0.0' + }, + channels: { + Exchange: { + address: null, + messages: { + FooEvent: { + name: 'FooEvent', + title: 'Tenant Created', + contentType: 'application/json', + payload: { + type: 'string' + } + } + } + } + }, + operations: { + sendTenantCreated: { + title: 'Send tenant created event to client', + action: 'send', + channel: { + $ref: '#/channels/Exchange' + }, + messages: [ + { + $ref: '#/channels/Exchange/messages/FooEvent' + } + ] + } + } + }; + const { document, diagnostics } = await parser.parse(documentRaw, { validateOptions: { allowedSeverity: { warning: false } } }); + console.log(diagnostics); + expect(diagnostics).toHaveLength(0); + }); });