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/src/models/asyncapi.ts b/src/models/asyncapi.ts index 6f85dc575..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.0.0'; +export const ParserAPIVersion = 2; export interface AsyncAPIDocumentInterface extends BaseModel, ExtensionsMixinInterface { version(): string; 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() {