cli: [BUG] The bundle command does not bundle referenced files
Describe the bug.
The CLI tool now accepts asyncapi bundle for v3 documents (thanks to fix of issue https://github.com/asyncapi/cli/issues/1137). However, it does not work as I expected, but of course I could be missing something.
I created a new default document with asyncapi new and moved the single message to a file in the same directory. Added a $ref in the main file. When I ran asyncapi bundle main.yaml on the new file, I expected it to merge the “message file”. But it didn’t.
main.yaml
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
userSignedUp:
address: user/signedup
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
operations:
onUserSignUp:
action: receive
channel:
$ref: '#/channels/userSignedUp'
messages:
- $ref: '#/channels/userSignedUp/messages/UserSignedUp'
components:
messages:
UserSignedUp:
$ref: './messages.yaml#/UserSignedUp'
messages.yaml
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user
Expected behavior
One yaml file containing the whole specification.
expected_bundle.yaml
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
userSignedUp:
address: user/signedup
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
operations:
onUserSignUp:
action: receive
channel:
$ref: '#/channels/userSignedUp'
messages:
- $ref: '#/channels/userSignedUp/messages/UserSignedUp'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user
Screenshots
How to Reproduce
- Extract
main.yamlandmessages.yamlto the same directory - In that directory, execute
asyncapi bundle main.yaml
🥦 Browser
None
👀 Have you checked for similar open issues?
- I checked and didn’t find similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue ?
None
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 30 (20 by maintainers)
Commits related to this issue
- test: replicate incorrect bundling and missing assertions part of #1323 — committed to francocm/asyncapi-cli by francocm 3 years ago
- Updated assertion styles as per PR feedback as part of https://github.com/asyncapi/cli/issues/1323 — committed to francocm/asyncapi-cli by francocm 3 years ago
- Fixed incorrect test and incorrect expected files as part of https://github.com/asyncapi/cli/issues/1323 — committed to francocm/asyncapi-cli by francocm 3 years ago
I’ll ask here since this issue already has the intended audience.
Should there be a separate mode in
Bundlerthat will dereference only external$refs, leaving internal$refs intact (previous behavior?)Thanks @aeworxet this issue seems to be resolved through your change.
I’ve noticed a new potential gap, which I’ve detailed in a comment in my tests PR here: https://github.com/asyncapi/cli/pull/1389#issuecomment-2102950792
I will be able to implement
bundleafter theonBundlecallback with the similar functionality asonDereferenceis introduced in@apidevtools/json-schema-ref-parser(I still need to do stuff after bundling and keep cmd switches consistent across versions.)@aeworxet if we leave the optimizer out of the picture for now, which of these options should be the output of the bundler?
I think option 2 should be the result. as a user of bundler I don’t expect bundler to de-reference my local references. If there is disagreement here, I think we should discuss this in a separate issue and see what the community wants.
Agreed.
@Amzani and @peter-rr I’ve raised a draft PR that replicates this problem: https://github.com/asyncapi/cli/pull/1389
I can try giving a look later at the root cause too, but in the meantime I hope that’s helpful.
Also, existing assertions that validated the output spec were not actually asserting for
to.be.true.