diff --git a/package-lock.json b/package-lock.json index 166874c25..a022c41e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/parser", - "version": "3.0.0-next-major-spec.2", + "version": "3.0.0-next-major-spec.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/parser", - "version": "3.0.0-next-major-spec.2", + "version": "3.0.0-next-major-spec.3", "license": "Apache-2.0", "dependencies": { "@asyncapi/specs": "^6.0.0-next-major-spec.6", diff --git a/package.json b/package.json index 3fe1762fc..21b43846c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/parser", - "version": "3.0.0-next-major-spec.2", + "version": "3.0.0-next-major-spec.3", "description": "JavaScript AsyncAPI parser.", "bugs": { "url": "https://github.com/asyncapi/parser-js/issues" 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() {