From 9fce88628623d6f8ee1fc0d270df8a7030577868 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Thu, 28 Sep 2023 21:20:17 +0200 Subject: [PATCH 1/3] fix problem --- src/document.ts | 2 +- test/document.spec.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/document.ts b/src/document.ts index 887fd02b9..b202b1c6a 100644 --- a/src/document.ts +++ b/src/document.ts @@ -43,7 +43,7 @@ export function isAsyncAPIDocument(maybeDoc: unknown): maybeDoc is AsyncAPIDocum } if (maybeDoc && typeof (maybeDoc as AsyncAPIDocumentInterface).json === 'function') { const versionOfParserAPI = (maybeDoc as AsyncAPIDocumentInterface).json()[xParserApiVersion]; - return versionOfParserAPI === 1; + return versionOfParserAPI === 2; } return false; } diff --git a/test/document.spec.ts b/test/document.spec.ts index 64b963218..dfa07761d 100644 --- a/test/document.spec.ts +++ b/test/document.spec.ts @@ -114,8 +114,12 @@ describe('utils', function() { expect(isAsyncAPIDocument(createAsyncAPIDocument(detailed))).toEqual(true); }); - it('document with the x-parser-api-version extension set to 1 should be AsyncAPI document', async function() { - expect(isAsyncAPIDocument({ json() { return { [xParserApiVersion]: 1 }; } })).toEqual(true); + it('document with the x-parser-api-version extension set to 2 should be AsyncAPI document', async function() { + expect(isAsyncAPIDocument({ json() { return { [xParserApiVersion]: 2 }; } })).toEqual(true); + }); + + it('document with the x-parser-api-version extension set to 1 should not be AsyncAPI document', async function() { + expect(isAsyncAPIDocument({ json() { return { [xParserApiVersion]: 1 }; } })).toEqual(false); }); it('document with the x-parser-api-version extension set to 0 should not be AsyncAPI document', async function() { From e421da0942574ec721de2f0889fea7de97e3a444 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Fri, 29 Sep 2023 11:13:01 +0200 Subject: [PATCH 2/3] revert parser api version --- src/models/asyncapi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/asyncapi.ts b/src/models/asyncapi.ts index 6f85dc575..43ae620dd 100644 --- a/src/models/asyncapi.ts +++ b/src/models/asyncapi.ts @@ -12,7 +12,7 @@ import type { ServersInterface } from './servers'; import type { v2, v3 } from '../spec-types'; // https://github.com/asyncapi/parser-api/releases/tag/v2.0.0 -export const ParserAPIVersion = '2.0.0'; +export const ParserAPIVersion = '2'; export interface AsyncAPIDocumentInterface extends BaseModel, ExtensionsMixinInterface { version(): string; From 87d60c42c368ae252f290cfaf4f13b612f03d8c9 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Tue, 3 Oct 2023 11:56:37 +0200 Subject: [PATCH 3/3] revert to number --- src/models/asyncapi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/asyncapi.ts b/src/models/asyncapi.ts index 43ae620dd..ce1e2b8a5 100644 --- a/src/models/asyncapi.ts +++ b/src/models/asyncapi.ts @@ -12,7 +12,7 @@ import type { ServersInterface } from './servers'; import type { v2, v3 } from '../spec-types'; // https://github.com/asyncapi/parser-api/releases/tag/v2.0.0 -export const ParserAPIVersion = '2'; +export const ParserAPIVersion = 2; export interface AsyncAPIDocumentInterface extends BaseModel, ExtensionsMixinInterface { version(): string;