asyncapi / asyncapi/generator

[BUG] :Hardcoded AsyncAPI file path in JavaScript WebSocket client template breaks non-asyncapi.yaml specs and portability

Open Beginner friendly
#1,903 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.1k
Forks
397
Avg merge
1d 7h
Merged PRs (30d)
25

Description

### 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

Image

### 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](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)

### Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start with packages/templates/clients/websocket/javascript/template/client.js.js and inspect how params.asyncapiFileDir is used to construct the spec path. Verify how the generator passes the user's source filename, then check generated clients for asyncapi.yaml, asyncapi.yml, and asyncapi.json. Done means the generated client references the provided filename rather than assuming asyncapi.yaml.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.