[BUG] bundle creates invalid document (refs)
Describe the bug.
asyncapi bundle creates invalid documents.
main.yaml
asyncapi: 3.0.0
info:
title: demo
version: '1'
operations:
A:
$ref: "./_sub.yaml#/components/operations/A"
channels:
A:
$ref: "./_sub.yaml#/components/channels/A"
_sub.yaml
components:
operations:
A:
action: send
channel:
$ref: '#/components/channels/A'
messages:
- $ref: '#/components/channels/A/messages/A'
channels:
A:
messages:
A:
$ref: '#/components/messages/A'
messages:
A:
payload:
type: object
asyncapi validate main.yaml
asyncapi bundle ./main.yaml --output final.yml
asyncapi validate final.yml
produced invalid output:
asyncapi: 3.0.0
info:
title: demo
version: '1'
channels:
A:
messages:
A:
payload:
type: object
operations:
A:
action: send
channel:
$ref: '#/components/channels/A'
messages:
- $ref: '#/components/channels/A/messages/A'
Expected behavior
It should've either updated the refs to root or moved the channels/ops/messages to components (if allowed).
Screenshots
How to Reproduce
see above
🖥️ Device Information [optional]
- Operating System (OS): macOS latest
- Browser: WF
- Browser Version: latest
👀 Have you checked for similar open issues?
- [x] I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
- [x] I have read the Contributing Guidelines
Are you willing to work on this issue ?
No, someone else can work on it
When I move channels and operations to root the produced doc is fine.
Hey @Shurtu-gal @Souvikns @AayushSaini101 ,
Edit: My earlier comment was about asyncapi optimize, which is not relevant to this issue — thanks for flagging that.
For asyncapi bundle, the problem is that the bundled output keeps $refs pointing to #/components/... while the actual channels, operations, and messages are moved to the root, resulting in an invalid document.
The bundler should either rewrite $refs to the new root paths or keep the referenced definitions under components consistently.
@Varadraj75 did you mean to post this here (vs. in my optimize bug ticket)? This issue is about bundling.
@black-snow Thanks for the clarification — you’re right, my earlier comment was about optimize, not bundle.
For bundling, the issue seems to be that $refs still point to #/components/... even though the bundled output moves channels/operations/messages to the root, making the document invalid.
The bundler should either rewrite those $refs to the new root paths or keep the definitions under components consistently.
Should i work on it?
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart: