Skip to content

refactor: simplify prop passing to ClientClass by using asyncapi object #1571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8afd069
Describe your changes here
Aditya08Vashisht May 21, 2025
3365d83
Merge branch 'master' into fix-prop-passing
Aditya08Vashisht May 25, 2025
6660f56
Update ClientClass.js
Aditya08Vashisht May 25, 2025
b860ddd
Update client.py.js
Aditya08Vashisht May 25, 2025
4ae08af
Merge branch 'master' into fix-prop-passing
Aditya08Vashisht Jun 4, 2025
b40d7da
Resolve merge conflict in client.py.js
Aditya08Vashisht Jun 4, 2025
b6eba47
Update client.py.js
Aditya08Vashisht Jun 4, 2025
7b587f6
refactor: update ClientClass to match asyncapi prop refactor
Aditya08Vashisht Jun 4, 2025
400f099
refactor: update ClientClass to match asyncapi prop refactor
Aditya08Vashisht Jun 4, 2025
21c8ac9
refactor: update ClientClass to match asyncapi prop refactor
Aditya08Vashisht Jun 4, 2025
e7e5dec
refactor: update ClientClass to match asyncapi prop refactor
Aditya08Vashisht Jun 4, 2025
a36e685
refactor: update ClientClass to match asyncapi prop refactor
Aditya08Vashisht Jun 4, 2025
e00cba7
Update client.py.js
Aditya08Vashisht Jun 4, 2025
4de91fc
Update ClientClass.js
Aditya08Vashisht Jun 4, 2025
d836304
Update client.py.js
Aditya08Vashisht Jun 4, 2025
dc2ee8f
Update ClientClass.js
Aditya08Vashisht Jun 4, 2025
30f1640
Update client.py.js
Aditya08Vashisht Jun 4, 2025
ed8af2f
Update client.py.js
Aditya08Vashisht Jun 4, 2025
276d2dd
fix: restore removed components and helpers, cleaned incorrect additions
Aditya08Vashisht Jun 6, 2025
04b1115
Merge branch 'master' into fix-prop-passing
Aditya08Vashisht Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Text } from '@asyncapi/generator-react-sdk';
import { getClientName, getServerUrl, getServer } from '@asyncapi/generator-helpers';

Check failure on line 2 in packages/templates/clients/websocket/python/components/ClientClass.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

'getServer' is defined but never used

Check failure on line 2 in packages/templates/clients/websocket/python/components/ClientClass.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

'getServerUrl' is defined but never used

Check failure on line 2 in packages/templates/clients/websocket/python/components/ClientClass.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

'getClientName' is defined but never used
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Complete the refactoring to use imported helper functions.

The helper functions are imported but never used, causing ESLint errors. This indicates incomplete implementation of the intended refactoring to use the asyncapi object.

Based on the PR objectives and past review comments, the function signature should be updated to use these helpers:

-export function ClientClass({ clientName, serverUrl, title, queryParams }) {
+export function ClientClass({ asyncapi, params }) {
+  if (!asyncapi) {
+    throw new Error('Missing required "asyncapi" context.');
+  }
+  if (!params || !params.server) {
+    throw new Error('Missing required "server" param.');
+  }
+  
+  const info = asyncapi.info();
+  const clientName = getClientName(info);
+  const server = getServer(asyncapi.servers(), params.server);
+  const serverUrl = getServerUrl(server);
+  const title = info.title();
+  const queryParams = params.queryParams;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { getClientName, getServerUrl, getServer } from '@asyncapi/generator-helpers';
import { getClientName, getServerUrl, getServer } from '@asyncapi/generator-helpers';
export function ClientClass({ asyncapi, params }) {
if (!asyncapi) {
throw new Error('Missing required "asyncapi" context.');
}
if (!params || !params.server) {
throw new Error('Missing required "server" param.');
}
const info = asyncapi.info();
const clientName = getClientName(info);
const server = getServer(asyncapi.servers(), params.server);
const serverUrl = getServerUrl(server);
const title = info.title();
const queryParams = params.queryParams;
// …rest of the component implementation…
}
🧰 Tools
🪛 GitHub Check: Test NodeJS PR - ubuntu-latest

[failure] 2-2:
'getServer' is defined but never used


[failure] 2-2:
'getServerUrl' is defined but never used


[failure] 2-2:
'getClientName' is defined but never used

🪛 GitHub Actions: PR testing - if Node project

[error] 2-2: ESLint: 'getClientName' is defined but never used. (no-unused-vars)

🤖 Prompt for AI Agents
In packages/templates/clients/websocket/python/components/ClientClass.js at line
2, the imported helper functions getClientName, getServerUrl, and getServer from
'@asyncapi/generator-helpers' are not used, causing ESLint errors. Refactor the
code to replace any direct usage of the asyncapi object with these helper
functions by updating the function signatures and calls accordingly to utilize
getClientName, getServerUrl, and getServer for cleaner and consistent code.

import { Constructor } from './Constructor';
import { Connect } from './Connect';
import { RegisterMessageHandler } from './RegisterMessageHandler';
Expand All @@ -9,6 +10,7 @@
import { RegisterOutgoingProcessor } from './RegisterOutgoingProcessor';
import { HandleError } from './HandleError';


Check failure on line 13 in packages/templates/clients/websocket/python/components/ClientClass.js

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

More than 1 blank line not allowed
export function ClientClass({ clientName, serverUrl, title, queryParams }) {
return (
<Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default function ({ asyncapi, params }) {
const queryParams = getQueryParams(asyncapi.channels());
const clientName = getClientName(info, params.appendClientSuffix, params.customClientName);
const serverUrl = getServerUrl(server);

return (
// The clientFileName default values can be found and modified under the package.json
<File name={params.clientFileName}>
<FileHeaderInfo
info={info}
Expand Down
Loading