generator icon indicating copy to clipboard operation
generator copied to clipboard

[BUG] WebSocket client templates do not resolve AsyncAPI server variable defaults

Open Khush7Chauhan opened this issue 1 month ago • 7 comments

Describe the bug.

The generated WebSocket client preserves an AsyncAPI server variable as a literal placeholder instead of using its declared default value. For example, {symbol} remains in the generated URL even though the server variable declares default: btcusd.

Expected behavior

The generated client should resolve server-variable defaults: this.url = url || 'wss://api.gemini.com/v1/marketdata/btcusd';

Screenshots

Image Image

How to Reproduce

Generate the Python WebSocket client using the repository fixture and inspect the generated constructor snapshot. The URL contains {symbol} instead of btcusd.

🖥️ Device Information [optional]

  • Operating System (OS): Windows 11
  • Browser: Not applicable
  • Browser Version: Not applicable

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Khush7Chauhan avatar Nov 01 '26 18:11 Khush7Chauhan

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

github-actions[bot] avatar Nov 01 '26 18:11 github-actions[bot]

Hi @Khush7Chauhan! I'm Dosu and I'm helping the AsyncAPI team. The missing substitution is in packages/helpers/src/servers.js: getServerUrl() combines the host, protocol and pathname, then returns the string without resolving server variables. The Python ClientClass passes that result straight into its constructor component. [1] [2]

For your PR, I'd start in that helper rather than adding Python-specific substitution. Add regression coverage in packages/helpers/test/servers.test.js for defaults in both host and pathname, repeated placeholders, and URLs without variables. The existing tests cover protocol handling and pathname concatenation, but not variable defaults. [3]

The Python fixture already provides withVariables, with /ws/{symbol} and default: btcusd, and the constructor snapshot currently expects the unresolved placeholder. After the fix, that fixture's expected URL should be wss://test.example.com/ws/btcusd. [4] [5]

One small clarification: the Python output uses a default argument such as def __init__(self, url: str = "…", ...), rather than the JavaScript this.url = url || ... form in the report. [6]

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about generator with Dosu Add Dosu to your team

dosubot[bot] avatar Nov 01 '26 18:11 dosubot[bot]

@dosu I would like to work on this, please assign it to me.

Khush7Chauhan avatar Nov 01 '26 18:11 Khush7Chauhan

Thanks, @Khush7Chauhan! I can’t change GitHub assignees from here, so a repository maintainer will need to handle assignment.

Your comment already signals that you want to work on this. Before opening a PR, wait for a core maintainer such as @Adi-204 to approve the issue with /approve. PRs linked to issues still marked Awaiting Approval are automatically closed. Once approved, include Fixes #2297 in your PR description. [1] [2]

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about generator with Dosu Add Dosu to your team

dosubot[bot] avatar Nov 01 '26 18:11 dosubot[bot]

Hey @Adi-204 , checking in on this bug. I have a solution ready to go—could you assign this to me or drop an /approve so I can push the PR?

Khush7Chauhan avatar Nov 05 '26 14:11 Khush7Chauhan

/approve

Adi-204 avatar Nov 05 '26 16:11 Adi-204

👋 Thanks for your patience. This issue has been reviewed and is ready to be worked on.

Before you start:

  • Comment below to let others know you're working on it (avoids duplicate work)
  • Read our CONTRIBUTING.md if you haven't already
  • Fork the repo, create a feature branch, and open a draft PR early

Approved by @Adi-204

asyncapi-bot avatar Nov 05 '26 16:11 asyncapi-bot