Skip to content
13 changes: 13 additions & 0 deletions .changeset/1891.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@asyncapi/cli': patch
---

fix: correct resolver configuration merge in ValidationService

- 29c22f1: fix: correct resolver configuration merge in ValidationService

Fixes #1839
- b4529e5: test: add regression test for resolver config merge bug
- 8246049: test: add integration test for external file reference resolution


3 changes: 2 additions & 1 deletion src/domains/services/validation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ export class ValidationService extends BaseService {
const customParserOptions = {
...parserOptions,
__unstable: {
...parserOptions.__unstable,
resolver: {
...parserOptions.__unstable?.resolver,
cache: false,
resolvers: [
createHttpWithAuthResolver(),
...(parserOptions.__unstable?.resolver?.resolvers || [])
],
},
...parserOptions.__unstable?.resolver,
},
};

Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/external-refs/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
asyncapi: "2.6.0"
info:
title: Service with External Refs
version: 1.0.0
description: AsyncAPI document with external file references in same directory
channels:
user/created:
subscribe:
message:
payload:
$ref: "./schemas.yaml#/components/schemas/UserSchema"
20 changes: 20 additions & 0 deletions test/fixtures/external-refs/schemas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
components:
schemas:
UserSchema:
type: object
properties:
id:
type: string
format: uuid
description: User ID
name:
type: string
description: User name
email:
type: string
format: email
description: User email
required:
- id
- name
- email
10 changes: 10 additions & 0 deletions test/integration/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ describe('validate', () => {
expect(ctx.stderr).to.equal('');
done();
});

test
.stderr()
.stdout()
.command(['validate', './test/fixtures/external-refs/main.yaml'])
.it('should resolve external file references in same directory', (ctx, done) => {
expect(ctx.stdout).to.include('File ./test/fixtures/external-refs/main.yaml is valid');
expect(ctx.stderr).to.equal('');
done();
});
});

describe('with context names', () => {
Expand Down