Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next-major-spec' into fix_channel_parameters
Browse files Browse the repository at this point in the history
jonaslagoni authored Oct 6, 2023
2 parents 85bcae5 + 07f3a2e commit ed0b851
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion src/document.ts
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion src/models/asyncapi.ts
Original file line number Diff line number Diff line change
@@ -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<v2.AsyncAPIObject | v3.AsyncAPIObject>, ExtensionsMixinInterface {
version(): string;
8 changes: 6 additions & 2 deletions test/document.spec.ts
Original file line number Diff line number Diff line change
@@ -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() {

0 comments on commit ed0b851

Please sign in to comment.