Skip to content

Commit 0a8406d

Browse files
Kartikayy007asyncapi-botShurtu-gal
authored
fix: correct resolver configuration merge in ValidationService (#1891)
* fix: correct resolver configuration merge in ValidationService Fixes #1839 * chore: add changeset for PR #1891 * test: add regression test for resolver config merge bug * chore: add changeset for PR #1891 * test: add integration test for external file reference resolution * chore: add changeset for PR #1891 * chore: delete changeset Deleting changeset as release workflow is not working right now. --------- Co-authored-by: asyncapi-bot <info@asyncapi.io> Co-authored-by: Ashish Padhy <ashishpadhy1729@gmail.com>
1 parent edac8c3 commit 0a8406d

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

src/domains/services/validation.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,15 @@ export class ValidationService extends BaseService {
184184
const customParserOptions = {
185185
...parserOptions,
186186
__unstable: {
187+
...parserOptions.__unstable,
187188
resolver: {
189+
...parserOptions.__unstable?.resolver,
188190
cache: false,
189191
resolvers: [
190192
createHttpWithAuthResolver(),
191193
...(parserOptions.__unstable?.resolver?.resolvers || [])
192194
],
193195
},
194-
...parserOptions.__unstable?.resolver,
195196
},
196197
};
197198

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
asyncapi: "2.6.0"
2+
info:
3+
title: Service with External Refs
4+
version: 1.0.0
5+
description: AsyncAPI document with external file references in same directory
6+
channels:
7+
user/created:
8+
subscribe:
9+
message:
10+
payload:
11+
$ref: "./schemas.yaml#/components/schemas/UserSchema"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
components:
2+
schemas:
3+
UserSchema:
4+
type: object
5+
properties:
6+
id:
7+
type: string
8+
format: uuid
9+
description: User ID
10+
name:
11+
type: string
12+
description: User name
13+
email:
14+
type: string
15+
format: email
16+
description: User email
17+
required:
18+
- id
19+
- name
20+
- email

test/integration/validate.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ describe('validate', () => {
8484
expect(ctx.stderr).to.equal('');
8585
done();
8686
});
87+
88+
test
89+
.stderr()
90+
.stdout()
91+
.command(['validate', './test/fixtures/external-refs/main.yaml'])
92+
.it('should resolve external file references in same directory', (ctx, done) => {
93+
expect(ctx.stdout).to.include('File ./test/fixtures/external-refs/main.yaml is valid');
94+
expect(ctx.stderr).to.equal('');
95+
done();
96+
});
8797
});
8898

8999
describe('with context names', () => {

0 commit comments

Comments
 (0)