[BUG] :Hardcoded AsyncAPI file path in JavaScript WebSocket client template breaks non-asyncapi.yaml specs and portability
Describe the bug.
IN the JavaScript WebSocket client template, the AsyncAPI spec file path is hardcoded to asyncapi.yaml, which causes incorrect behavior when users provide their AsyncAPI document in other supported formats such as .json or .yml.
This issue exists in the following template file: packages/templates/clients/websocket/javascript/template/client.js.js
Specifically, the template constructs the AsyncAPI file path like this:
const asyncapiFilepath = ${params.asyncapiFileDir}/asyncapi.yaml;
However, the Generator explicitly supports multiple AsyncAPI file formats (.yaml, .yml, .json). Hardcoding the filename makes the generated client incorrect or unusable when the input spec is not named asyncapi.yaml.
Actual Behavior
The generated client always references asyncapi.yaml Assumes the AsyncAPI file is always named asyncapi.yaml
Expected behavior
The client template should use the real AsyncAPI filename provided by the user
The generated client should work regardless of whether the spec is:
asyncapi.yaml asyncapi.yml asyncapi.json
Screenshots
How to Reproduce
Clone the Repo
Visit the Path :-packages/templates/clients/websocket/javascript/template/client.js.js
Analyze the Code
const asyncapiFilepath = ${params.asyncapiFileDir}/asyncapi.yaml;
🖥️ Device Information [optional]
- Operating System (OS):Windows 11
- Browser:BRAVE
- Browser Version:
👀 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 ?
Yes I am willing to submit a PR!
Hey, @Adi-204 Please have a look .
You’re right—this is a confirmed bug. The JavaScript WebSocket client template currently hardcodes the AsyncAPI spec filename as asyncapi.yaml, which breaks portability and support for .json or .yml specs. The template only receives the directory parameter (asyncapiFileDir), not the actual filename, and the generator infrastructure doesn’t expose the real filename to templates by default. That means there’s no way for the template to know if the file is asyncapi.yaml, asyncapi.json, or something else, unless you add a new parameter or update the generator core to pass the filename through as a template param source.
For a quick fix, you can add a new template parameter (like asyncapiFileName) to .ageneratorrc and update the template to use it. For a more robust solution, the generator core should be updated to automatically pass the actual spec filename to templates, so all templates can reference the correct file regardless of format or name. No existing PRs or issues address this yet, so your contribution would be valuable. Let me know if you want a step-by-step on how to implement either approach!
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
@dosu ,is this still a issue
Yes, this bug still exists. The hardcoded line remains unchanged in the current codebase [1]:
const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;
Worth noting: the generate:after hook (createAsyncapiFile) does dynamically detect the correct extension — it checks whether the source is JSON or YAML and writes the output file as asyncapi.json or asyncapi.yaml accordingly [2]. So the file copied to the output directory will have the correct extension.
The bug is that the generated client code still hardcodes asyncapi.yaml as the path, regardless of what the hook actually wrote. If the input spec is JSON, the hook writes asyncapi.json, but the client will try to load asyncapi.yaml — which won't exist.
No open PR addresses this yet, so a fix is still needed. The simplest approach would be to add a new template parameter (e.g. asyncapiFileName) or have the template replicate the hook's JSON-vs-YAML detection logic so the generated path matches the actual output file. Happy to walk through implementation details if you'd like to submit a PR!
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
@SHUBHANSHU602 it is valid issue!
ohk @Adi-204 .