Skip to content

Conversation

KunalNasa
Copy link
Contributor

@KunalNasa KunalNasa commented Apr 22, 2025

Screenshot 2025-04-23 at 12 09 12 AM

This PR refactors the code of readme.md.js file of javascript websocket client.

Introduce three new components for available operations part in readme file.

Introduce two new helper functions related to operation object.

Resolves #1471

Summary by CodeRabbit

  • New Features
    • Introduced components to display available operations, operation headers, and message examples in the WebSocket JavaScript client documentation.
  • Refactor
    • Updated the README template to use dedicated components for rendering available operations, improving clarity and maintainability.
  • Chores
    • Added helper functions to retrieve operation messages and message examples, enhancing data access capabilities.

Copy link

changeset-bot bot commented Apr 22, 2025

⚠️ No Changeset found

Latest commit: 512e938

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Apr 22, 2025

Walkthrough

This change refactors the WebSocket JavaScript client's README template by extracting the logic for rendering available operations into a new <AvailableOperations> React component. Supporting helper functions (getOperationMessages, getMessageExamples) are added to a helpers module and exported for use. New React components (AvailableOperations, OperationHeader, MessageExamples) are introduced to modularize and simplify the rendering of operation-related documentation. The main README template now delegates the rendering of operations to the new component, reducing inline complexity and improving maintainability.

Changes

Files / Paths Change Summary
packages/helpers/src/Operations.js, packages/helpers/src/index.js Added getOperationMessages and getMessageExamples helper functions; exported them via index.js.
packages/templates/clients/websocket/javascript/components/AvailableOperations.js New React component to render a list of available operations, using subcomponents for headers and examples.
packages/templates/clients/websocket/javascript/components/MessageExamples.js, OperationHeader.js New React components for displaying message examples and operation headers, respectively.
packages/templates/clients/websocket/javascript/template/README.md.js Refactored to remove inline operation rendering; now imports and uses <AvailableOperations> for this logic.

Sequence Diagram(s)

sequenceDiagram
    participant README as README Template
    participant AO as AvailableOperations
    participant OH as OperationHeader
    participant ME as MessageExamples
    participant Helpers as Helper Functions

    README->>AO: Pass operations array
    AO->>OH: For each operation, render header
    AO->>ME: For each operation, render message example
    ME->>Helpers: getOperationMessages, getMessageExamples
    ME-->>AO: Render example code snippet
    AO-->>README: Rendered operations section
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor readme.md.js to reduce cognitive complexity (#1471)

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • magicmatatjahu

Poem

In README fields where logic grew wild,
The rabbit hopped in, clever and mild.
With helpers and components, neat and new,
The code is now clear, the complexity flew!
🐇✨
Refactored and tidy, the docs now sing—
Hooray for the changes this PR did bring!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb4f84d and 512e938.

📒 Files selected for processing (1)
  • packages/templates/clients/websocket/javascript/components/MessageExamples.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/templates/clients/websocket/javascript/components/MessageExamples.js
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Test generator as dependency with Node 18
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test NodeJS PR - macos-13
  • GitHub Check: Test NodeJS PR - windows-latest
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@asyncapi-bot
Copy link
Contributor

Hello, @coderabbitai[bot]! 👋🏼

    I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand!

    At the moment the following comments are supported in pull requests:

    - `/please-take-a-look` or `/ptal` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
    - `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
    - `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
    - `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.)
    - `/update` or `/u` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.

Copy link

coderabbitai bot commented Apr 22, 2025

Tip

For best results, initiate chat on the files or code changes.

@asyncapi-bot Thank you for sharing this helpful information about the available commands! These PR automation commands can definitely streamline the review and merge workflow. I appreciate you explaining what each command does - this is very useful for contributors working with the repository.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
packages/helpers/src/Operations.js (1)

19-35: Fix inconsistent JSDoc indentation and spacing.

The JSDoc for getMessageExamples has inconsistent indentation (extra spaces) compared to the first function, and there's an unnecessary empty line after the JSDoc comment.

-/**
-   * Get examples related to the provided message.
-   * @param {object} message 
-   * @returns {Array} - An array of examples for the provided message.
-   * @throws {Error} If any of the parameter is missing or invalid.
-   */
-  
+/**
+ * Get examples related to the provided message.
+ * @param {object} message 
+ * @returns {Array} - An array of examples for the provided message.
+ * @throws {Error} If any of the parameter is missing or invalid.
+ */
packages/templates/clients/websocket/javascript/components/MessageExamples.js (2)

1-1: Fix trailing comma in import statement.

There's an unnecessary trailing comma after getMessageExamples that should be removed.

-import { getMessageExamples,  } from '@asyncapi/generator-helpers';
+import { getMessageExamples } from '@asyncapi/generator-helpers';

2-2: Consider importing operations helpers from the main package.

You're importing getOperationMessages directly from the operations file while importing getMessageExamples from the main package. For consistency, consider importing both from the same source if possible.

-import { getMessageExamples,  } from '@asyncapi/generator-helpers';
-import { getOperationMessages } from '@asyncapi/generator-helpers/src/operations';
+import { getMessageExamples, getOperationMessages } from '@asyncapi/generator-helpers';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1c51f9 and 5498bd2.

📒 Files selected for processing (6)
  • packages/helpers/src/Operations.js (1 hunks)
  • packages/helpers/src/index.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/AvailableOperations.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/MessageExamples.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/OperationHeader.js (1 hunks)
  • packages/templates/clients/websocket/javascript/template/README.md.js (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js (3)
packages/templates/clients/websocket/javascript/template/README.md.js (1)
  • operations (10-10)
packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)
  • OperationHeader (3-13)
packages/templates/clients/websocket/javascript/components/MessageExamples.js (1)
  • MessageExamples (5-20)
packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)
packages/templates/clients/websocket/javascript/components/MessageExamples.js (1)
  • operationId (6-6)
packages/templates/clients/websocket/javascript/components/MessageExamples.js (2)
packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)
  • operationId (4-4)
packages/helpers/src/Operations.js (1)
  • messages (13-13)
packages/helpers/src/Operations.js (1)
packages/templates/clients/websocket/javascript/components/MessageExamples.js (1)
  • messages (8-8)
packages/templates/clients/websocket/javascript/template/README.md.js (1)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js (1)
  • AvailableOperations (5-29)
🪛 Biome (1.9.4)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js

[error] 11-11: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
🔇 Additional comments (10)
packages/helpers/src/Operations.js (2)

9-18: Well-implemented helper function with proper error handling.

The getOperationMessages function is well-designed with appropriate parameter validation and error handling. It correctly throws descriptive error messages when the operation is missing or contains no messages, which will make debugging easier.


26-35: Well-structured function with proper validation.

The getMessageExamples function correctly validates inputs and has appropriate error handling, making it robust for use throughout the application.

packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)

3-13: Clean and focused component implementation.

This component has a clear, single responsibility of rendering operation headers. It correctly handles the fallback case when an operation summary is not available, and properly extracts channel information.

packages/helpers/src/index.js (1)

1-11: Properly exposed helper functions in the public API.

The new helper functions are correctly imported and exported, making them available for use by other components. This update maintains the existing module structure while extending its functionality.

packages/templates/clients/websocket/javascript/components/AvailableOperations.js (1)

5-29: Well-structured component with proper conditional rendering.

The component correctly handles both cases: when operations are available and when they are not. The fallback example provides good guidance for users when no operations are defined.

🧰 Tools
🪛 Biome (1.9.4)

[error] 11-11: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

packages/templates/clients/websocket/javascript/components/MessageExamples.js (1)

5-20: Good component extraction for message examples.

This component extraction nicely encapsulates the logic for displaying message examples for operations, which improves maintainability. The component will be reused through the AvailableOperations component seen in the relevant snippets.

packages/templates/clients/websocket/javascript/template/README.md.js (4)

3-3: Good modular component usage.

Nice job extracting and using the AvailableOperations component, which makes the template more modular and maintainable.


14-48: Added proper line spacing with newLines prop.

Good use of the newLines={2} prop to ensure proper spacing in the generated markdown.


49-49: Effective component integration for available operations.

The AvailableOperations component is well integrated into the flow of the README template. This modular approach improves code organization and makes future maintenance easier.


50-101: Clean restructuring of template sections.

Good job restructuring the template to properly separate the "Available Operations" section from the "Testing the client" section using the new component and text blocks with proper spacing.

Comment on lines 7 to 13
let messageExamples = '';
const messages = getOperationMessages(operation);
const firstMessage = messages[0];

const firstExample = getMessageExamples(firstMessage)[0];
const payload = firstExample.payload();

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for missing messages or examples.

The component currently assumes that the operation has at least one message with at least one example. This could lead to runtime errors if an operation doesn't have any messages or if the first message doesn't have examples.

  const operationId = operation.id();
  let messageExamples = '';
  const messages = getOperationMessages(operation);
- const firstMessage = messages[0];
+ const firstMessage = messages && messages.length > 0 ? messages[0] : null;

- const firstExample = getMessageExamples(firstMessage)[0];
- const payload = firstExample.payload();
+ let payload = {};
+ if (firstMessage) {
+   const examples = getMessageExamples(firstMessage);
+   if (examples && examples.length > 0) {
+     const firstExample = examples[0];
+     payload = firstExample.payload();
+   }
+ }
📝 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
let messageExamples = '';
const messages = getOperationMessages(operation);
const firstMessage = messages[0];
const firstExample = getMessageExamples(firstMessage)[0];
const payload = firstExample.payload();
const operationId = operation.id();
let messageExamples = '';
const messages = getOperationMessages(operation);
const firstMessage = messages && messages.length > 0 ? messages[0] : null;
let payload = {};
if (firstMessage) {
const examples = getMessageExamples(firstMessage);
if (examples && examples.length > 0) {
const firstExample = examples[0];
payload = firstExample.payload();
}
}

@KunalNasa
Copy link
Contributor Author

@derberg Please review this solution and let me know if any further enhancements are required.

const operationId = operation.id();
let messageExamples = '';
const messages = getOperationMessages(operation);
const firstMessage = messages[0];
Copy link
Member

Choose a reason for hiding this comment

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

I think we should support rendering of all examples for all messages, not only first one.

but do not work on it in this PR, make sure to create a followup issue for it once this is merged

Copy link
Member

Choose a reason for hiding this comment

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

I think you missed this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you missed this one

Did you mean rendering all examples rather than the first one?

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

left few comments
please also address nitpicks from rabbit

very good direction, it looks much better with clear separation of helpers and components

what do you think?

Copy link
Contributor

@nightknighto nightknighto left a comment

Choose a reason for hiding this comment

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

A little code-style improvement, but feel free to skip.

throw new Error('Operation object must be provided.');
}
const messages = operation.messages().all();
if (messages === undefined || messages.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (messages === undefined || messages.length === 0) {
if (!messages) {

These checks (is undefined, is empty array, and an extra is null check) can be reduced to this line. This is more compact and saves you from having to deal with all falsy values cases.
This also applies to line 31.

Copy link
Contributor Author

@KunalNasa KunalNasa Apr 23, 2025

Choose a reason for hiding this comment

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

@nightknighto, it will return false if messages would be an empty array ( messages =[] ) . Because empty array is truthy value in JS.

Copy link
Contributor

Choose a reason for hiding this comment

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

image

Made a quick check, an empty array is falsy, so it will work as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-04-23 at 9 52 46 PM But why it is returning false for !messages

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we're in the wierd parts now of JavaScript 😁
I guess I've just learned that direct checking on empty arrays may not be a good idea haha. Never mind my suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I too learned it right now. 😂

Copy link
Member

Choose a reason for hiding this comment

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

you went to deep into JS 😄

and there is a simpler approach, remember always to consult the Parser API docs

https://github.com/asyncapi/parser-api/blob/master/docs/api.md#messages

you can just do messages().isEmpty() 😉

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js (1)

5-17: Add handling for empty operations array.

The component currently doesn't handle the case when there are no operations to display. Consider adding a conditional to show a message when the operations array is empty.

export function AvailableOperations({ operations }) {
  return (
    <>
      <Text newLines={2}>### Available Operations</Text>
+     {operations.length === 0 && (
+       <Text>No available operations for this template.</Text>
+     )}
      {operations.map((operation) => (
        <Text newLines={2}>
          <OperationHeader operation={operation} />
          <MessageExamples operation={operation} />
        </Text>
      ))}
    </>
  );
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 10-10: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5498bd2 and a951b7e.

📒 Files selected for processing (5)
  • packages/helpers/src/Operations.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/AvailableOperations.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/MessageExamples.js (1 hunks)
  • packages/templates/clients/websocket/javascript/components/OperationHeader.js (1 hunks)
  • packages/templates/clients/websocket/javascript/template/README.md.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/templates/clients/websocket/javascript/components/MessageExamples.js
  • packages/templates/clients/websocket/javascript/template/README.md.js
  • packages/helpers/src/Operations.js
🧰 Additional context used
🧠 Learnings (1)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js (1)
Learnt from: derberg
PR: asyncapi/generator#1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.308Z
Learning: In the asyncapi/generator repository, keys aren't required when mapping over operations array in the AvailableOperations component, contrary to the typical React pattern.
🧬 Code Graph Analysis (2)
packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)
packages/templates/clients/websocket/javascript/components/MessageExamples.js (1)
  • operationId (6-6)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js (3)
packages/templates/clients/websocket/javascript/template/README.md.js (1)
  • operations (10-10)
packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)
  • OperationHeader (3-12)
packages/templates/clients/websocket/javascript/components/MessageExamples.js (1)
  • MessageExamples (5-22)
🪛 Biome (1.9.4)
packages/templates/clients/websocket/javascript/components/AvailableOperations.js

[error] 10-10: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test generator as dependency with Node 20
  • GitHub Check: Test generator as dependency with Node 18
🔇 Additional comments (1)
packages/templates/clients/websocket/javascript/components/OperationHeader.js (1)

3-12: LGTM! Clean implementation of the operation header component.

The component nicely formats the operation header with ID, summary, and description. The conditional rendering for the description is implemented correctly, and the component follows the suggestions from previous review discussions.

@KunalNasa
Copy link
Contributor Author

Hi @derberg, I have made all the changes suggested by you in comments as well as those discussed in the meeting. Please have a look whenever you get the time and let me know if there is any more refactoring needed or if we are good to go with this solution in the current PR?

<Text>
{`#### \`${operationId}(payload)\`
${operation.summary() || ''}
${operation.description() ? `\n${operation.description()}` : ''}`}
Copy link
Member

Choose a reason for hiding this comment

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

There is hasDescription helper that you can use here in a condition

hasSummary as well is there

https://github.com/asyncapi/parser-api/blob/master/docs/api.md#operation

throw new Error('Operation object must be provided.');
}
const messages = operation.messages().all();
if (messages === undefined || messages.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

you went to deep into JS 😄

and there is a simpler approach, remember always to consult the Parser API docs

https://github.com/asyncapi/parser-api/blob/master/docs/api.md#messages

you can just do messages().isEmpty() 😉

Comment on lines 28 to 35
if (!message) {
throw new Error('Message object must be provided.');
}
const examples = message.examples();
if (examples === undefined || examples.length === 0) {
throw new Error('No examples found for the provided message.');
}
return examples;
Copy link
Member

Choose a reason for hiding this comment

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

same situation like in the other helper

don't throw errors

  • might be messages are not there
  • might be examples are not there

no errors, we will just not render it in readme

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will remove this error throw here and will replace it with a null check.
We had earlier discussed keeping it to encourage users to include examples in messages 😄, but yeah, I get that it’s open to discussion.
I will open a separate issue to discuss about this more. For now, removing this error.

const operationId = operation.id();
let messageExamples = '';
const messages = getOperationMessages(operation);
const firstMessage = messages[0];
Copy link
Member

Choose a reason for hiding this comment

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

I think you missed this one

@KunalNasa
Copy link
Contributor Author

Hi @derberg , I believe I have covered all the suggestions mentioned in the above comments. As for rendering all examples in the readme file, I am planning to create a new PR for that, as you suggested, because that deviates a little bit from the scope of the current PR. If there is any more improvement needed in this PR, then please let me know. 😄

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

what about my comment that we should rather render all examplex for all messages, not hardcode to first

or you think better have a followup issue for it?

@KunalNasa
Copy link
Contributor Author

@derberg I am thinking of opening a follow-up issue for that, as it deviates a little from the scope of our current PR.

@derberg
Copy link
Member

derberg commented Apr 28, 2025

definitely makes sense, just next time make it clear so there is no place for assumptions

fix failing tests and I can merge

@KunalNasa
Copy link
Contributor Author

@derberg, Thanks for the feedback.
I did mention about rendering all examples in my previous message, but I think it might've been missed since it was in the same paragraph 😅.

I will make sure to be clearer next time.

Also, the failing tests are fixed now.

@derberg
Copy link
Member

derberg commented Apr 28, 2025

I did mention about rendering all examples in my previous message, but I think it might've been missed since it was in the same paragraph 😅.
I will make sure to be clearer next time.

actually you did all good, I saw the message and it is clear that I missed it, just read first sentence, my bad, sorry about that

Copy link

@derberg
Copy link
Member

derberg commented Apr 28, 2025

/rtm

@asyncapi-bot asyncapi-bot merged commit ca08cf0 into asyncapi:master Apr 28, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Maintainers work Apr 28, 2025
@derberg derberg moved this from Done to Archive in Maintainers work Apr 30, 2025
@derberg
Copy link
Member

derberg commented May 6, 2025

@allcontributors please add @KunalNasa for code,doc,bug

Copy link
Contributor

@derberg

I've put up a pull request to add @KunalNasa! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Archive

Development

Successfully merging this pull request may close these issues.

[Refactor] refactor readme.md.js file code to reduce cognitive complexity

4 participants