Skip to content

Commit

Permalink
Merge branch 'next-major-spec' into update_specs
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya authored Aug 11, 2023
2 parents 2f0d707 + b34825c commit 93e67db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 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": "2.1.0-next-major-spec.6",
"version": "2.1.0-next-major-spec.7",
"description": "JavaScript AsyncAPI parser.",
"bugs": {
"url": "https://github.com/asyncapi/parser-js/issues"
Expand Down
2 changes: 1 addition & 1 deletion src/models/v3/asyncapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AsyncAPIDocument extends BaseModel<v3.AsyncAPIObject> implements As
}

schemas() {
return null as any;
return this.__schemas(false);
}

securitySchemes(): SecuritySchemesInterface {
Expand Down
21 changes: 20 additions & 1 deletion test/models/v3/asyncapi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Components } from '../../../src/models/v3/components';
import { Info } from '../../../src/models/v3/info';
import { Messages } from '../../../src/models/v3/messages';
import { Operations } from '../../../src/models/v3/operations';
import { Schemas } from '../../../src/models/v3/schemas';
import { SecuritySchemes } from '../../../src/models/v3/security-schemes';
import { Servers } from '../../../src/models/v3/servers';

Expand Down Expand Up @@ -127,7 +128,25 @@ describe('AsyncAPIDocument model', function() {
});

describe('.schemas()', function() {
it.todo('should return a collection of schemas');
it('should return a collection of schemas', function() {
const doc = serializeInput<v3.AsyncAPIObject>({ channels: { userSignup: { address: 'user/signup', messages: { someMessage1: { payload: {}}, someMessage2: { payload: {} } } }, userLogout: { address: 'user/logout', messages: { someMessage3WithoutPayload: {} } } } });
const d = new AsyncAPIDocument(doc);
expect(d.schemas()).toBeInstanceOf(Schemas);
expect(d.schemas()).toHaveLength(2);
});

it('should return only an "used" schemas (without schemas from components)', function() {
const doc = serializeInput<v3.AsyncAPIObject>({ channels: { userSignup: { address: 'user/signup', messages: { someMessage1: { payload: {}}, someMessage2: { payload: {} } } } }, components: { schemas: { schemaOne: {}, schemaTwo: {} } } });
const d = new AsyncAPIDocument(doc);
expect(d.schemas()).toBeInstanceOf(Schemas);
expect(d.schemas()).toHaveLength(2);
});

it('should return a collection of schemas even if collection is empty', function() {
const doc = serializeInput<v3.AsyncAPIObject>({});
const d = new AsyncAPIDocument(doc);
expect(d.schemas()).toBeInstanceOf(Schemas);
});
});

describe('.securitySchemes()', function() {
Expand Down

0 comments on commit 93e67db

Please sign in to comment.