From d5f2b4a1b28de8c2116fcf2c08ae000161388a2c Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Mon, 24 Jul 2023 20:11:55 +0200 Subject: [PATCH] additional changes --- src/commands/diff.ts | 7 ++++++- test/commands/diff.test.ts | 16 +++++++++++++--- test/specification-v3.yml | 2 -- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/commands/diff.ts b/src/commands/diff.ts index 60b9a1205fc..c515fafc26f 100644 --- a/src/commands/diff.ts +++ b/src/commands/diff.ts @@ -88,7 +88,7 @@ export default class Diff extends Command { firstDocument = await load(firstDocumentPath); if (firstDocument.isAsyncAPI3()) { - this.error('Diff command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/diff/issues/154'); + this.error('Diff command does not support AsyncAPI v3 yet which was your first document, please checkout https://github.com/asyncapi/diff/issues/154'); } enableWatch(watchMode, { @@ -112,6 +112,11 @@ export default class Diff extends Command { try { secondDocument = await load(secondDocumentPath); + + if (secondDocument.isAsyncAPI3()) { + this.error('Diff command does not support AsyncAPI v3 yet which was your second document, please checkout https://github.com/asyncapi/diff/issues/154'); + } + enableWatch(watchMode, { spec: secondDocument, handler: this, diff --git a/test/commands/diff.test.ts b/test/commands/diff.test.ts index 67e0b12d22f..fb4efa9c1f3 100644 --- a/test/commands/diff.test.ts +++ b/test/commands/diff.test.ts @@ -2,6 +2,7 @@ import { test } from '@oclif/test'; const asyncapiv3 = './test/specification-v3.yml'; +const asyncapiv2 = './test/specification.yml'; const noChangesJson = '"{\\n \\"changes\\": []\\n}\\n"'; const breakingChangesJson = '"[\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/servers/mosquitto/protocol\\",\\n \\"before\\": \\"mqtt\\",\\n \\"after\\": \\"http\\",\\n \\"type\\": \\"breaking\\"\\n },\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/servers/mosquitto/url\\",\\n \\"before\\": \\"mqtt://test.mosquitto.org\\",\\n \\"after\\": \\"http://test.mosquitto.org\\",\\n \\"type\\": \\"breaking\\"\\n }\\n]\\n"'; const nonBreakingChangesJson = '"[\\n {\\n \\"action\\": \\"add\\",\\n \\"path\\": \\"/channels/user~1signedup\\",\\n \\"after\\": {\\n \\"subscribe\\": {\\n \\"message\\": {\\n \\"payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"x-parser-message-name\\": \\"UserSignedUp\\",\\n \\"x-parser-original-schema-format\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"schemaFormat\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"x-parser-original-payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"x-parser-message-parsed\\": true\\n }\\n }\\n },\\n \\"type\\": \\"non-breaking\\"\\n },\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/info/title\\",\\n \\"before\\": \\"Streetlights API\\",\\n \\"after\\": \\"Streetlights API V2\\",\\n \\"type\\": \\"non-breaking\\"\\n },\\n {\\n \\"action\\": \\"add\\",\\n \\"path\\": \\"/components\\",\\n \\"after\\": {\\n \\"messages\\": {\\n \\"UserSignedUp\\": {\\n \\"payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"x-parser-message-name\\": \\"UserSignedUp\\",\\n \\"x-parser-original-schema-format\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"schemaFormat\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"x-parser-original-payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"\\"\\n },\\n \\"x-parser-message-parsed\\": true\\n }\\n }\\n },\\n \\"type\\": \\"non-breaking\\"\\n }\\n]\\n"'; @@ -21,9 +22,18 @@ describe('diff', () => { test .stderr() .stdout() - .command(['diff', asyncapiv3, asyncapiv3]) - .it('give error', (ctx, done) => { - expect(ctx.stderr).toEqual('Error: Diff command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/diff/issues/154\n'); + .command(['diff', asyncapiv3, asyncapiv2]) + .it('give error when first document', (ctx, done) => { + expect(ctx.stderr).toEqual('Error: Diff command does not support AsyncAPI v3 yet which was your first document, please checkout https://github.com/asyncapi/diff/issues/154\n'); + expect(ctx.stdout).toEqual(''); + done(); + }); + test + .stderr() + .stdout() + .command(['diff', asyncapiv2, asyncapiv3]) + .it('give error when second document', (ctx, done) => { + expect(ctx.stderr).toEqual('Error: Diff command does not support AsyncAPI v3 yet which was your second document, please checkout https://github.com/asyncapi/diff/issues/154\n'); expect(ctx.stdout).toEqual(''); done(); }); diff --git a/test/specification-v3.yml b/test/specification-v3.yml index ad5aac63b32..93cdabbb181 100644 --- a/test/specification-v3.yml +++ b/test/specification-v3.yml @@ -256,5 +256,3 @@ components: parameters: streetlightId: description: The ID of the streetlight. - schema: - type: string