Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-ref-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@asyncapi/cli": patch
---

Fix bug where external files in the same directory were not correctly resolved via `$ref`.
7 changes: 4 additions & 3 deletions src/domains/models/SpecificationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ export class Specification {

static async fromFile(filepath: string) {
let spec;
const absolutePath = path.resolve(process.cwd(), filepath);
try {
spec = await readFile(filepath, { encoding: 'utf8' });
spec = await readFile(absolutePath, { encoding: 'utf8' });
} catch {
throw new ErrorLoadingSpec('file', filepath);
throw new ErrorLoadingSpec('file', absolutePath);
}
return new Specification(spec, { filepath });
return new Specification(spec, { filepath: absolutePath });
}

static async fromURL(URLpath: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/domains/services/generator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class GeneratorService extends BaseService {
try {
await generator.generateFromString(asyncapi.text(), {
...genOption,
path: asyncapi,
path: asyncapi.getSource(),
});
} catch (err: unknown) {
s.stop('Generation failed');
Expand Down
Loading