cli
cli copied to clipboard
Cannot convert AsyncAPI document
Describe the bug
While trying to use asyncapi convert ... I get a successful message and an error.
How to Reproduce
Given the following file:
{
"asyncapi": "2.2.0",
"info": {
"title": "Rust server",
"description": "test",
"version": "0.8.0",
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"servers": {
"production": {
"url": "148.251.43.103:4222",
"protocol": "nats",
"description": "GamingAPI NATS production broker"
}
},
"defaultContentType": "json",
"channels": {
"v0/rust/servers/events/started": {
"description": "Channel for the API to process for when a server has started",
"subscribe": {
"operationId": "ServerStarted",
"description": "The Rust server can publish to this channel when the server has started",
"message": {
"payload": {
"type": "string"
}
}
}
}
}
}
With the following command asyncapi convert ./documents/test.json -o ./documents/output.json
I get the following output:
File ./documents/test.json successfully converted!
TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object
``
#### Expected behavior
Expected the file to be converted.
It might be related to the change in the API of the converter. The result of the conversion is not string and this is why writing to output maybe fails. @peter-rr do you have time to have a look? we are also missing a test of conversion with `--output flag.
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:
@peter-rr hey, any chance you could have a look?
@derberg Sure! Let me check it 👀
I've been testing with different files and formats and it seems the error is only happening with .json files. The writeFile() function does not accept an instance of Object as an argument, so that the converted file is not saved as an output file.
When --output flag is not passed, we can see the file is actually converted except for the "subscribe" object as you can see in the following log:

I've come up with a quick fix which seems to solve the issue. The output is not properly formatted, though 🤔

Let me know what you think :) Also I need to add a test of conversion for --output flag.
cool! left a comment
:tada: This issue has been resolved in version 0.39.3 :tada:
The release is available on:
Your semantic-release bot :package::rocket: