Skip to content

Commit

Permalink
fix: add check that $ref value is a string (#92)
Browse files Browse the repository at this point in the history
Co-authored-by: Maciej Urbańczyk <[email protected]>
  • Loading branch information
aeworxet and magicmatatjahu committed Nov 3, 2022
1 parent 7a0fb39 commit 8fab690
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/lib/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,36 @@ describe('bundler should ', () => {

expect(message.$ref).toMatch('#/components/messages/UserSignedUp');
});

test('should not throw if value of `$ref` is not a string', async () => {
const files = ['./tests/wrong-ref-not-string.yaml'];
const response = await bundle(
files.map(file =>
fs.readFileSync(path.resolve(process.cwd(), file), 'utf-8')
),
{
referenceIntoComponents: true,
}
);

const result = response.json();

expect(result).toBeDefined();
});

test('should not throw if value of `$ref` is absent', async () => {
const files = ['./tests/wrong-ref-absent.yaml'];
const response = await bundle(
files.map(file =>
fs.readFileSync(path.resolve(process.cwd(), file), 'utf-8')
),
{
referenceIntoComponents: true,
}
);

const result = response.json();

expect(result).toBeDefined();
});
});
10 changes: 10 additions & 0 deletions tests/wrong-ref-absent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
asyncapi: '2.2.0'
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
user/signedup:
subscribe:
message:
$ref:
10 changes: 10 additions & 0 deletions tests/wrong-ref-not-string.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
asyncapi: '2.2.0'
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
user/signedup:
subscribe:
message:
$ref: 5

0 comments on commit 8fab690

Please sign in to comment.