Skip to content

fix: external files in same directory are not resolved.#2129

Merged
asyncapi-bot merged 3 commits intoasyncapi:masterfrom
AayushSaini101:1839
Apr 24, 2026
Merged

fix: external files in same directory are not resolved.#2129
asyncapi-bot merged 3 commits intoasyncapi:masterfrom
AayushSaini101:1839

Conversation

@AayushSaini101
Copy link
Copy Markdown
Collaborator

@AayushSaini101 AayushSaini101 commented Apr 21, 2026

Description

  • Fixes relative file $ref resolution when the main AsyncAPI file lives in a subdirectory (e.g. src/contract/asyncapi.yaml) and references sibling YAML files. Those references were resolved from the process working directory instead of the spec’s directory.
  • Cause: @asyncapi/generator only passes a parse source (base URI) when parseOptions.path is a string. The CLI passed a Specification object, so the parser never received a base URI.
  • Change: In GeneratorService, pass a proper base URI for the generator: file:// URL for on-disk specs (absolute path) and the existing URL string for remote specs. GeneratorRunOptions.path is typed as string to match the generator.
  • Adds a regression fixture under test/fixtures/generate-same-dir-ref/ and an integration test in fromTemplate.test.ts (“same-directory file $ref”).

Related issue(s)
Fixes #1839

Related: #2039
How to test

npm run build
npx mocha ... test/integration/generate/fromTemplate.test.ts -g "same-directory" (or full test suite as in CI)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

⚠️ No Changeset found

Latest commit: 1cfe700

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@AayushSaini101 AayushSaini101 changed the title fix:external files in same directory are not resolved via anymore, s… fix:external files in same directory are not resolved. Apr 21, 2026
@AayushSaini101 AayushSaini101 changed the title fix:external files in same directory are not resolved. fix: external files in same directory are not resolved. Apr 21, 2026
@AayushSaini101
Copy link
Copy Markdown
Collaborator Author

/u

@AayushSaini101
Copy link
Copy Markdown
Collaborator Author

Server API testing:
image

Server API starting:
image

@github-project-automation github-project-automation Bot moved this from To Triage to Backlog in CLI - Kanban Apr 24, 2026
@AayushSaini101
Copy link
Copy Markdown
Collaborator Author

/rtm

@AayushSaini101
Copy link
Copy Markdown
Collaborator Author

/u

@AayushSaini101
Copy link
Copy Markdown
Collaborator Author

/rtm

@sonarqubecloud
Copy link
Copy Markdown

@asyncapi-bot asyncapi-bot merged commit f84d532 into asyncapi:master Apr 24, 2026
21 of 22 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in CLI - Kanban Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] external files in same directory are not resolved via $ref anymore, since v3.3.0

3 participants