Skip to content

docs: add api generation for components#1767

Merged
asyncapi-bot merged 52 commits intoasyncapi:masterfrom
batchu5:api-generation-for-components
Feb 4, 2026
Merged

docs: add api generation for components#1767
asyncapi-bot merged 52 commits intoasyncapi:masterfrom
batchu5:api-generation-for-components

Conversation

@batchu5
Copy link
Contributor

@batchu5 batchu5 commented Nov 23, 2025

Description

Adds automated API documentation generation for components using jsdoc-to-markdown and a custom Handlebars template.
This improves consistency and readability of the generated API.md file.

Changes

  • Added jsdoc-to-markdown v9.1.13 as a development dependency
  • Updated package.json scripts:
    • generate:assets now runs both prepublishOnly and docs
    • docs uses jsdoc2md with a custom api.hbs template to generate API.md
  • Added api.hbs to define the structure and layout of the final API documentation
  • Enabled automatic conversion of JSDoc comments from all files under src/**/*.js into a clean Markdown API file

Related issue(s)

Resolves #1656

Summary by CodeRabbit

  • New Features

    • Docs generation added to asset workflow and a comprehensive API document published.
  • Documentation

    • Extensive JSDoc expansions and examples, tightened nullable/type annotations, new docs template and an escape-type helper, plus generated API output.
  • Refactor

    • Multiple modules changed to named exports and central exports updated.
  • Behavior

    • Added runtime guards that return/throw clearer results for unsupported language/config combinations.
  • Chores

    • Added docs script and jsdoc-to-markdown dev dependency.
  • Tests

    • Updated tests to reflect export/import changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2025

⚠️ No Changeset found

Latest commit: 6d16479

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

@asyncapi-bot
Copy link
Contributor

What reviewer looks at during PR review

The following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.

  1. PR Title: Use a concise title that follows our Conventional Commits guidelines and clearly summarizes the change using imperative mood (it means spoken or written as if giving a command or instruction, like "add new helper for listing operations")

    Note - In Generator, prepend feat: or fix: in PR title only when PATCH/MINOR release must be triggered.

  2. PR Description: Clearly explain the issue being solved, summarize the changes made, and mention the related issue.

    Note - In Generator, we use Maintainers Work board to track progress. Ensure the PR Description includes Resolves #<issue-number> or Fixes #<issue-number> this will automatically close the linked issue when the PR is merged and helps automate the maintainers workflow.

  3. Documentation: Update the relevant Generator documentation to accurately reflect the changes introduced in the PR, ensuring users and contributors have up-to-date guidance.

  4. Comments and JSDoc: Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions, so others can easily understand and use the code.

  5. DRY Code: Ensure the code follows the Don't Repeat Yourself principle. Look out for duplicate logic that can be reused.

  6. Test Coverage: Ensure the new code is well-tested with meaningful test cases that pass consistently and cover all relevant edge cases.

  7. Commit History: Contributors should avoid force-pushing as much as possible. It makes it harder to track incremental changes and review the latest updates.

  8. Template Design Principles Alignment: While reviewing template-related changes in the packages/ directory, ensure they align with the Assumptions and Principles. If any principle feels outdated or no longer applicable, start a discussion these principles are meant to evolve with the project.

  9. Reduce Scope When Needed: If an issue or PR feels too large or complex, consider splitting it and creating follow-up issues. Smaller, focused PRs are easier to review and merge.

  10. Bot Comments: As reviewers, check that contributors have appropriately addressed comments or suggestions made by automated bots. If there are bot comments the reviewer disagrees with, react to them or mark them as resolved, so the review history remains clear and accurate.

@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
📝 Walkthrough

Walkthrough

Adds jsdoc2md tooling (script, helper, template) and committed API.md; tightens numerous JSDoc typedefs and examples; converts several default exports to named exports; introduces a few runtime guards/early returns; updates package.json scripts and devDependency. Most edits are documentation, typings, and export adjustments.

Changes

Cohort / File(s) Summary
Build & docs generation
packages/components/package.json, packages/components/jsdoc2md-handlebars/api.hbs, packages/components/jsdoc2md-helpers/jsdoc-helper.js, packages/components/docs/API.md
Add docs script and jsdoc-to-markdown devDependency; make generate:assets run prepublishOnly && docs; add Handlebars template and escapeType helper; commit generated API.md.
JSDoc typedef tightening & examples (WebSocket related)
packages/components/src/components/CloseConnection.js, packages/components/src/components/HandleMessage.js, packages/components/src/components/RegisterErrorHandler.js, packages/components/src/components/RegisterMessageHandler.js
Change { methodDocs?: string } → `{ methodDocs: string
Method/Model/Send typings & private helpers
packages/components/src/components/MethodGenerator.js, packages/components/src/components/Models.js, packages/components/src/components/SendOperations.js
Make method-related typedefs explicit (`...
Query params typedefs & guard
packages/components/src/components/QueryParamsVariables.js
Rename SupportedLanguageLanguage; make QueryParamCodeBlock numeric fields explicit; adjust closing shape; add @private docs and examples; add early null return when resolver missing.
Language alias & mappings across components
packages/components/src/components/Connect.js, .../OnClose.js, .../OnError.js, .../OnMessage.js, .../OnOpen.js, .../SendOperations.js, .../Models.js
Replace SupportedLanguage with Language in typedefs and JSDoc, update mapping/type annotations and examples; OnOpen adds runtime guard and resolveOpenConfig returns null when not found.
Readme-style components & exports (readme/...)
packages/components/src/components/readme/AvailableOperations.js, .../CoreMethods.js, .../OperationHeader.js, .../MessageExamples.js, .../Overview.js, .../Readme.js, .../Usage.js, .../Installation.js
Add/expand README-style JSDoc and examples; introduce CoreMethods with unsupported-language runtime error; convert several modules from default to named exports; add public typedefs; Installation/Overview now render Text blocks for content.
DependencyProvider & FileHeader docs / rendering
packages/components/src/components/DependencyProvider.js, packages/components/src/components/FileHeaderInfo.js
Mark internal helper resolveDependencies as @private, clarify return descriptions and examples; DependencyProvider now documents and returns a Text component containing joined dependencies.
Exports, tests & index updates
packages/components/src/components/readme/MessageExamples.js, .../OperationHeader.js, packages/components/test/components/MessageExamples.test.js, packages/components/test/components/OperationHeader.test.js, packages/components/src/index.js
Convert MessageExamples and OperationHeader to named exports; update tests imports; add AvailableOperations, OperationHeader, MessageExamples exports to package src/index.js.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding API documentation generation for components using automated tooling.
Linked Issues check ✅ Passed All requirements from issue #1656 are met: API.md generation, integration into npm run generate:assets workflow, and JSDoc-based documentation collection.
Out of Scope Changes check ✅ Passed All changes are scoped to API documentation generation goals. JSDoc updates, component exports, and template additions directly support the issue objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 11

🧹 Nitpick comments (1)
packages/components/src/components/Models.js (1)

22-26: Reconsider the @Class documentation placement.

This @class JSDoc block documents ModelinaGenerator, but this class is not defined in this file—it's an external type imported from @asyncapi/modelina (e.g., PythonGenerator, JavaGenerator, etc. on lines 3-9).

Documenting external classes in your own codebase can be misleading to maintainers and documentation generators. Consider either:

  1. Removing this block entirely and relying on the library's own documentation
  2. Using @typedef to create a type alias that references the external generator classes

If you want to keep type documentation, use a typedef instead:

-/**
- * @class ModelinaGenerator
- * @classdesc Represents a Modelina generator class.
- * @param {object} [options] - Optional generator options.
- */
+/**
+ * @typedef {import('@asyncapi/modelina').PythonGenerator | import('@asyncapi/modelina').JavaGenerator | import('@asyncapi/modelina').TypeScriptGenerator | import('@asyncapi/modelina').CSharpGenerator | import('@asyncapi/modelina').RustGenerator | import('@asyncapi/modelina').JavaScriptGenerator} ModelinaGenerator
+ * Represents any Modelina generator class instance.
+ */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc9f60 and 3ff3f65.

📒 Files selected for processing (11)
  • packages/components/API.md (1 hunks)
  • packages/components/api.hbs (1 hunks)
  • packages/components/package.json (2 hunks)
  • packages/components/src/components/CloseConnection.js (1 hunks)
  • packages/components/src/components/HandleMessage.js (1 hunks)
  • packages/components/src/components/MethodGenerator.js (2 hunks)
  • packages/components/src/components/Models.js (1 hunks)
  • packages/components/src/components/QueryParamsVariables.js (1 hunks)
  • packages/components/src/components/RegisterErrorHandler.js (1 hunks)
  • packages/components/src/components/RegisterMessageHandler.js (1 hunks)
  • packages/components/src/components/SendOperations.js (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with action property (send/receive) and references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe operations
3. Messages are defined under a 'messages' container in channels
4. The specification decouples operations, channels and messages to improve reusability
5. Servers can use a 'host' property

Applied to files:

  • packages/components/src/components/SendOperations.js
  • packages/components/API.md
📚 Learning: 2025-05-12T14:23:48.919Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1551
File: apps/generator/docs/generator-template.md:45-73
Timestamp: 2025-05-12T14:23:48.919Z
Learning: AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x:
1. Operations become top-level elements with references to channels
2. Channels use 'address' for the topic path instead of having nested publish/subscribe
3. Messages are defined under a 'messages' container in channels
4. Servers can use a 'host' property

Applied to files:

  • packages/components/API.md
📚 Learning: 2025-05-12T14:57:35.024Z
Learnt from: Adi-204
Repo: asyncapi/generator PR: 1557
File: packages/templates/clients/websocket/javascript/components/SendOperation.js:21-21
Timestamp: 2025-05-12T14:57:35.024Z
Learning: In the AsyncAPI generator templates, particularly in the JavaScript WebSocket client, single quotes are used for string literals inside template-generated code (which is itself inside backticks) to preserve template placeholders like ${variable} as literal text in the generated code output.

Applied to files:

  • packages/components/API.md
🪛 LanguageTool
packages/components/API.md

[grammar] ~2-~2: Use a hyphen to join words.
Context: ...ection method with optional pre and post execution logic.

Parameters

| Name...

(QB_NEW_EN_HYPHEN)


[grammar] ~54-~54: Use a hyphen to join words.
Context: ...andler method with optional pre and post execution logic.

Parameters

| Name...

(QB_NEW_EN_HYPHEN)


[grammar] ~150-~150: Use a hyphen to join words.
Context: ...ration method with optional pre and post execution logic.

Parameters

| Name...

(QB_NEW_EN_HYPHEN)


[grammar] ~163-~163: Use a hyphen to join words.
Context: ...ration method with optional pre and post execution logic.

Parameters

| Name...

(QB_NEW_EN_HYPHEN)

🪛 markdownlint-cli2 (0.18.1)
packages/components/API.md

4-4: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


17-17: Multiple headings with the same content

(MD024, no-duplicate-heading)


18-18: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


25-25: Multiple headings with the same content

(MD024, no-duplicate-heading)


26-26: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


34-34: Multiple headings with the same content

(MD024, no-duplicate-heading)


35-35: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


45-45: Multiple headings with the same content

(MD024, no-duplicate-heading)


46-46: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


55-55: Multiple headings with the same content

(MD024, no-duplicate-heading)


56-56: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


72-72: Multiple headings with the same content

(MD024, no-duplicate-heading)


73-73: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


86-86: Table column count
Expected: 3; Actual: 4; Too many cells, extra data will be missing

(MD056, table-column-count)


90-90: Multiple headings with the same content

(MD024, no-duplicate-heading)


91-91: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


102-102: Multiple headings with the same content

(MD024, no-duplicate-heading)


103-103: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


111-111: Multiple headings with the same content

(MD024, no-duplicate-heading)


112-112: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


118-118: Multiple headings with the same content

(MD024, no-duplicate-heading)


119-119: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


125-125: Multiple headings with the same content

(MD024, no-duplicate-heading)


126-126: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


134-134: Multiple headings with the same content

(MD024, no-duplicate-heading)


135-135: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


142-142: Multiple headings with the same content

(MD024, no-duplicate-heading)


143-143: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


151-151: Multiple headings with the same content

(MD024, no-duplicate-heading)


152-152: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


164-164: Multiple headings with the same content

(MD024, no-duplicate-heading)


165-165: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


177-177: Multiple headings with the same content

(MD024, no-duplicate-heading)


178-178: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

🔇 Additional comments (4)
packages/components/src/components/Models.js (1)

30-30: LGTM: Improved type reference.

Changing from an inline constructor signature to the named ModelinaGenerator type improves readability and maintainability.

packages/components/src/components/SendOperations.js (1)

9-24: LGTM: Well-structured type definitions.

The new SendOperationMethods and SendOperationGenerator type definitions improve code documentation and type clarity. The refactoring from an inline type to named types makes the API more maintainable.

packages/components/package.json (2)

13-13: No issues found — jsdoc2md command and paths are correctly configured.

The verification confirms:

  • Template file api.hbs exists at packages/components/api.hbs
  • Glob pattern ./src/**/*.js correctly matches all 16 source files ✓
  • Relative path resolution works as expected from the npm script execution context ✓

43-43: No issues found—version 9.1.3 is current and compatible.

jsdoc-to-markdown v9.1.3 requires Node.js >= 12.17.0, and the version was released on October 3, 2025, making it current. The specified version is appropriate for the project.

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: 1

♻️ Duplicate comments (1)
packages/components/API.md (1)

1-193: Update JSDoc comments in four component files to correct hyphenation.

The auto-generated API.md reflects the current state of JSDoc comments in source files. Verification confirms that grammar issues identified in the previous review have not yet been fixed. Update "pre and post execution" to "pre- and post-execution" in the following files:

  • packages/components/src/components/CloseConnection.js
  • packages/components/src/components/HandleMessage.js
  • packages/components/src/components/RegisterErrorHandler.js
  • packages/components/src/components/RegisterMessageHandler.js

Once source JSDoc is corrected, the auto-generated API.md will reflect these changes.

🧹 Nitpick comments (1)
packages/components/package.json (1)

15-19: Consider adding API.md to the published package files.

The files array currently excludes the auto-generated API.md. Since this is user-facing API documentation, consider whether it should be included in npm package distributions for end-users to reference.

If API.md should be published, add it to the files array:

   "files": [
     "lib/**",
     "README.md",
+    "API.md",
     "LICENSE"
   ],

Alternatively, if API.md is only for the repository, ensure it's in .gitignore and document this decision.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 810948d and 431b8d1.

📒 Files selected for processing (3)
  • packages/components/API.md (1 hunks)
  • packages/components/api.hbs (1 hunks)
  • packages/components/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/api.hbs
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-04-23T09:18:38.333Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
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.

Applied to files:

  • packages/components/package.json
📚 Learning: 2025-05-12T14:57:35.024Z
Learnt from: Adi-204
Repo: asyncapi/generator PR: 1557
File: packages/templates/clients/websocket/javascript/components/SendOperation.js:21-21
Timestamp: 2025-05-12T14:57:35.024Z
Learning: In the AsyncAPI generator templates, particularly in the JavaScript WebSocket client, single quotes are used for string literals inside template-generated code (which is itself inside backticks) to preserve template placeholders like ${variable} as literal text in the generated code output.

Applied to files:

  • packages/components/API.md
🪛 LanguageTool
packages/components/API.md

[grammar] ~2-~2: Use a hyphen to join words.
Context: ...ection method with optional pre and post execution logic. ### Parameters | Name |...

(QB_NEW_EN_HYPHEN)


[grammar] ~58-~58: Use a hyphen to join words.
Context: ...andler method with optional pre and post execution logic. ### Parameters | Name |...

(QB_NEW_EN_HYPHEN)


[grammar] ~157-~157: Use a hyphen to join words.
Context: ...ration method with optional pre and post execution logic. ### Parameters | Name |...

(QB_NEW_EN_HYPHEN)


[grammar] ~171-~171: Use a hyphen to join words.
Context: ...ration method with optional pre and post execution logic. ### Parameters | Name |...

(QB_NEW_EN_HYPHEN)

🪛 markdownlint-cli2 (0.18.1)
packages/components/API.md

4-4: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


18-18: Multiple headings with the same content

(MD024, no-duplicate-heading)


19-19: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


26-26: Multiple headings with the same content

(MD024, no-duplicate-heading)


27-27: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


33-33: Multiple headings with the same content

(MD024, no-duplicate-heading)


36-36: Multiple headings with the same content

(MD024, no-duplicate-heading)


37-37: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


45-45: Multiple headings with the same content

(MD024, no-duplicate-heading)


48-48: Multiple headings with the same content

(MD024, no-duplicate-heading)


49-49: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


56-56: Multiple headings with the same content

(MD024, no-duplicate-heading)


59-59: Multiple headings with the same content

(MD024, no-duplicate-heading)


60-60: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


70-70: Multiple headings with the same content

(MD024, no-duplicate-heading)


77-77: Multiple headings with the same content

(MD024, no-duplicate-heading)


78-78: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


91-91: Table column count
Expected: 3; Actual: 4; Too many cells, extra data will be missing

(MD056, table-column-count)


95-95: Multiple headings with the same content

(MD024, no-duplicate-heading)


96-96: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


105-105: Multiple headings with the same content

(MD024, no-duplicate-heading)


108-108: Multiple headings with the same content

(MD024, no-duplicate-heading)


109-109: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


117-117: Multiple headings with the same content

(MD024, no-duplicate-heading)


118-118: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


124-124: Multiple headings with the same content

(MD024, no-duplicate-heading)


125-125: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


131-131: Multiple headings with the same content

(MD024, no-duplicate-heading)


132-132: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


140-140: Multiple headings with the same content

(MD024, no-duplicate-heading)


141-141: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


146-146: Multiple headings with the same content

(MD024, no-duplicate-heading)


149-149: Multiple headings with the same content

(MD024, no-duplicate-heading)


150-150: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


158-158: Multiple headings with the same content

(MD024, no-duplicate-heading)


159-159: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


169-169: Multiple headings with the same content

(MD024, no-duplicate-heading)


172-172: Multiple headings with the same content

(MD024, no-duplicate-heading)


173-173: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)


182-182: Multiple headings with the same content

(MD024, no-duplicate-heading)


186-186: Multiple headings with the same content

(MD024, no-duplicate-heading)


187-187: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

🔇 Additional comments (1)
packages/components/package.json (1)

43-43: Dependency version is appropriate.

The jsdoc-to-markdown v9.1.3 version with caret constraint ^9.1.3 is suitable for this use case, allowing patch and minor updates while maintaining stability.

@batchu5 batchu5 force-pushed the api-generation-for-components branch from ef164c0 to c521c81 Compare November 23, 2025 17:00
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: 1

🧹 Nitpick comments (1)
packages/components/package.json (1)

15-19: Consider adding API.md to the published files array.

The API.md file is generated by the docs script and added to the published package alongside README.md and LICENSE. Confirm whether it should be included in the files array for distribution to package consumers.

If API.md is meant to be published, apply this diff:

  "files": [
    "lib/**",
    "README.md",
+   "API.md",
    "LICENSE"
  ],
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef164c0 and c521c81.

📒 Files selected for processing (1)
  • packages/components/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-04-23T09:18:38.333Z
Learnt from: derberg
Repo: asyncapi/generator PR: 1512
File: packages/templates/clients/websocket/javascript/components/AvailableOperations.js:10-15
Timestamp: 2025-04-23T09:18:38.333Z
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.

Applied to files:

  • packages/components/package.json
🔇 Additional comments (1)
packages/components/package.json (1)

12-13: Cross-platform script fixes and glob quoting are correctly applied.

The scripts properly use && for sequential execution (addressing the prior Unix-only & issue) and the glob pattern is correctly quoted for cross-platform compatibility. The workflow ensures docs runs after prepublishOnly to generate API documentation.

@sonarqubecloud
Copy link

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

Hey @batchu5, sorry for the delay in the review process. If you’re still interested in working on this PR, could you please resolve the merge conflicts and update the PR? I’ll review it once that’s done.

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: 1

🤖 Fix all issues with AI agents
In @packages/components/package.json:
- Line 13: The "docs" npm script uses the jsdoc2md CLI but the package
jsdoc-to-markdown is not declared in devDependencies; add "jsdoc-to-markdown" to
the package.json devDependencies (or run npm/yarn add --dev jsdoc-to-markdown)
so the jsdoc2md command is available for "docs" and "generate:assets"; update
the devDependencies block to include the exact package name and a compatible
version and run install to ensure the CLI is present.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34f53ff and 228a776.

📒 Files selected for processing (2)
  • packages/components/package.json
  • packages/components/src/components/SendOperations.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/src/components/SendOperations.js
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: asyncapi/generator PR: 0
File: .github/pr-review-checklist.md:0-0
Timestamp: 2026-01-05T09:57:34.800Z
Learning: Update relevant Generator documentation to accurately reflect PR changes introduced
Learnt from: CR
Repo: asyncapi/generator PR: 0
File: .github/pr-review-checklist.md:0-0
Timestamp: 2026-01-05T09:57:34.800Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions
📚 Learning: 2026-01-05T09:57:34.800Z
Learnt from: CR
Repo: asyncapi/generator PR: 0
File: .github/pr-review-checklist.md:0-0
Timestamp: 2026-01-05T09:57:34.800Z
Learning: Update relevant Generator documentation to accurately reflect PR changes introduced

Applied to files:

  • packages/components/package.json
📚 Learning: 2026-01-05T09:57:34.800Z
Learnt from: CR
Repo: asyncapi/generator PR: 0
File: .github/pr-review-checklist.md:0-0
Timestamp: 2026-01-05T09:57:34.800Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions

Applied to files:

  • packages/components/package.json
🔇 Additional comments (2)
packages/components/package.json (2)

15-20: LGTM!

Including API.md in the published files ensures consumers have access to the generated API documentation.


12-12: LGTM!

The workflow correctly builds first (prepublishOnly) before running docs generation, ensuring the lib/ directory exists when jsdoc2md processes ./lib/**/*.js.

@batchu5 batchu5 requested a review from jonaslagoni as a code owner January 12, 2026 03:00
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: 1

🤖 Fix all issues with AI agents
In `@packages/components/src/components/OnOpen.js`:
- Around line 8-12: The JSDoc for websocketOnOpenMethod is incorrect: it
currently declares Object.<Language, Function> but the map includes entries like
the java key that are objects of framework-specific functions; update the JSDoc
to accurately reflect the union shape (e.g., a Function or a map of
framework->Function) or add a typedef for the framework map and reference it;
locate websocketOnOpenMethod (and the java entry) in OnOpen.js and change the
comment to a union/typedef type that documents both Function and
Object.<Framework, Function>.
🧹 Nitpick comments (3)
packages/components/src/components/readme/CoreMethods.js (2)

3-6: Minor typedef formatting inconsistency.

There's an extra space before the closing brace in the union type.

✏️ Suggested fix
-/**
- * `@typedef` {'python' | 'javascript' } Language
- * Supported programming languages.
- */
+/**
+ * Supported programming languages.
+ * `@typedef` {'python' | 'javascript'} Language
+ */

This also moves the description before the @typedef tag, which is the conventional JSDoc placement for typedef descriptions.


37-39: Consider adding defensive handling for unsupported languages.

If language is not 'python' or 'javascript', methodConfig[language] returns undefined, causing a runtime error on destructuring at line 39. While the Language typedef documents valid inputs, adding a guard could improve robustness.

🛡️ Optional defensive check
 export function CoreMethods({ language }) {
   const config = methodConfig[language];
+  if (!config) {
+    throw new Error(`Unsupported language: ${language}. Expected 'python' or 'javascript'.`);
+  }
   const { msgHandler, errHandler } = config;

This is a defensive coding suggestion for future-proofing; the current implementation works correctly when used as documented.

packages/components/src/components/HandleMessage.js (1)

10-10: Type annotation doesn't match actual data structure.

The python entry (lines 13-18) omits methodDocs entirely, but the type declares it as methodDocs: string | undefined (property must exist, value can be undefined). For a property that may be absent, use optional syntax.

Suggested fix
-* `@type` {Record<Language, { methodDocs: string | undefined, methodLogic: string }>}
+* `@type` {Record<Language, { methodDocs?: string, methodLogic: string }>}

@batchu5 batchu5 force-pushed the api-generation-for-components branch from 2be5fc0 to c4583e3 Compare January 26, 2026 17:29
@batchu5
Copy link
Contributor Author

batchu5 commented Jan 26, 2026

@Adi-204, I have made the changes as per the last conversation. Could you please review once more?

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

@batchu5 you can please fix the linting issue by running npm run lint:fix

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/components/src/components/OnClose.js (1)

91-96: Guard against undefined generateOnCloseCode to prevent TypeError.

When language='java' but framework is invalid (e.g., 'spring'), websocketOnCloseMethod['java'] exists (passes line 91 check), but resolveCloseConfig returns undefined. Line 93 then throws TypeError: generateOnCloseCode is not a function.

🐛 Proposed fix
   if (websocketOnCloseMethod[language]) {
     const generateOnCloseCode = resolveCloseConfig(language, framework);
-    const closeResult = generateOnCloseCode(title);
-    onCloseMethod = closeResult.onCloseMethod;
-    indent = closeResult.indent ?? 0;
+    if (typeof generateOnCloseCode === 'function') {
+      const closeResult = generateOnCloseCode(title);
+      onCloseMethod = closeResult.onCloseMethod;
+      indent = closeResult.indent ?? 0;
+    }
   }
packages/components/src/components/OnOpen.js (1)

85-94: Throw on unsupported language to match the @throws contract.
Right now, an unknown language silently returns an empty Text, which contradicts the JSDoc and can hide misconfigurations. Consider failing fast when the language isn’t supported.

🐛 Proposed fix
-  if (websocketOnOpenMethod[language]) {
-    const generateOnOpenCode = resolveOpenConfig(language, framework);
-    if (typeof generateOnOpenCode !== 'function') {
-      throw new Error(`Unsupported onOpen handler for language="${language}" framework="${framework}"`);
-    }
-    const openResult = generateOnOpenCode(title);
-    onOpenMethod = openResult.onOpenMethod;
-    indent = openResult.indent ?? 0;
-    newLines = openResult.newLines ?? 1;
-  }
+  if (!websocketOnOpenMethod[language]) {
+    throw new Error(`Unsupported onOpen handler for language="${language}" framework="${framework}"`);
+  }
+  const generateOnOpenCode = resolveOpenConfig(language, framework);
+  if (typeof generateOnOpenCode !== 'function') {
+    throw new Error(`Unsupported onOpen handler for language="${language}" framework="${framework}"`);
+  }
+  const openResult = generateOnOpenCode(title);
+  onOpenMethod = openResult.onOpenMethod;
+  indent = openResult.indent ?? 0;
+  newLines = openResult.newLines ?? 1;
🤖 Fix all issues with AI agents
In `@packages/components/src/components/MethodGenerator.js`:
- Around line 19-23: Add explicit `@param` and `@returns` JSDoc tags to the two
private helper functions in MethodGenerator.js (the one documented by the
"Resolve docs and logic for the given language + framework config." block and
the other helper around the 44-48 region). For each helper, document all
parameters by name with a brief type/description and add a `@returns` tag
describing the return value/type; keep the existing `@private` tag and ensure the
JSDoc names match the actual function parameter names so IDEs and linters pick
them up.

In `@packages/components/src/components/readme/CoreMethods.js`:
- Around line 19-35: The JSDoc for the CoreMethods component does not document
that it can throw for unsupported languages; update the comment block for
CoreMethods to include a `@throws` tag describing the error condition (e.g., when
props.language is not recognized) and the type/shape of the thrown error,
referencing the component name CoreMethods and the props.language parameter so
callers know this function may throw for unsupported language values.
🧹 Nitpick comments (1)
packages/components/src/components/OnClose.js (1)

50-58: Add JSDoc for resolveCloseConfig helper function.

This function lacks documentation. Per coding guidelines, functions should have clear JSDoc comments including parameter types, return values, and error conditions.

📝 Suggested JSDoc
+/**
+ * Resolves the appropriate onClose code generator for the given language and optional framework.
+ *
+ * `@param` {Language} language - The target programming language.
+ * `@param` {string} [framework=''] - Optional framework variant (e.g., 'quarkus' for java).
+ * `@returns` {Function|undefined} The code generator function, or undefined if not found.
+ */
 const resolveCloseConfig = (language, framework = '') => {

Based on learnings, JSDoc comments should cover parameter types, return values, and error conditions.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/components/src/components/OnClose.js (1)

58-66: Potential crash when language requires a framework but none is provided.

If language is 'java' and framework is empty/undefined, resolveCloseConfig returns undefined. Line 101 then calls generateOnCloseCode(title) on undefined, causing a runtime error.

🐛 Proposed fix: add a guard before invoking the generator
   if (websocketOnCloseMethod[language]) {
     const generateOnCloseCode = resolveCloseConfig(language, framework);
+    if (!generateOnCloseCode) {
+      return <Text indent={0}>{''}</Text>;
+    }
     const closeResult = generateOnCloseCode(title);
     onCloseMethod = closeResult.onCloseMethod;
     indent = closeResult.indent ?? 0;
   }

Alternatively, consider logging a warning or throwing a descriptive error when a required framework is missing for nested configurations.

Also applies to: 99-104

@batchu5 batchu5 force-pushed the api-generation-for-components branch from 283b318 to 5e4b4d9 Compare January 28, 2026 05:27
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/components/src/components/MethodGenerator.js (1)

10-17: JSDoc type is missing parameterWrap property.

The type annotation at line 10 doesn't include parameterWrap, but all runtime configurations (lines 13-16) define this property. This creates a mismatch between the documented type and the actual object shape.

Suggested fix
-* `@type` {Record<Language, { returnType: string | undefined, openingTag: string | undefined, closingTag: string | undefined, indentSize: number | undefined }>}
+* `@type` {Record<Language, { returnType: string | undefined, openingTag: string | undefined, closingTag: string | undefined, indentSize: number | undefined, parameterWrap: boolean | undefined }>}
🧹 Nitpick comments (2)
packages/components/src/components/MethodGenerator.js (2)

29-48: Return type may not accurately reflect possible undefined values.

The @returns annotation declares { docs: string, logic: string }, but when no config matches and methodDocs/methodLogic weren't provided, the function returns { docs: undefined, logic: undefined } (lines 32-33, 48).

Suggested fix
-* `@returns` {{ docs: string, logic: string }}
+* `@returns` {{ docs: string | undefined, logic: string | undefined }}

91-120: Example doesn't demonstrate the framework-level override path.

The example sets framework = "quarkus" (line 101), but methodConfig at line 100 doesn't have a nested framework structure. For the framework path (lines 38-41) to be exercised, the config should nest under the framework key:

const methodConfig = {"java" : {"quarkus": {methodDocs: methodDocs, methodLogic: methodLogic }}};

With the current example, the code falls through to the language-level path (lines 42-44) since config["quarkus"] is undefined. The example still works but doesn't illustrate the framework feature it appears to demonstrate.

Suggested fix to demonstrate framework-level configuration
-* const methodConfig = {"java" : {methodDocs : methodDocs, methodLogic: methodLogic }};
+* const methodConfig = {"java" : {"quarkus": {methodDocs : methodDocs, methodLogic: methodLogic }}};

@batchu5 batchu5 force-pushed the api-generation-for-components branch from 5e4b4d9 to cc3ff8d Compare January 28, 2026 05:54
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/components/src/components/MethodGenerator.js (1)

10-17: JSDoc type is missing parameterWrap property.

The defaultMethodConfig type annotation omits parameterWrap, which is present in all language configurations (lines 13-16). This inconsistency will cause the generated API docs to be incomplete.

Suggested fix
-* `@type` {Record<Language, { returnType: string | undefined, openingTag: string | undefined, closingTag: string | undefined, indentSize: number | undefined }>}
+* `@type` {Record<Language, { returnType: string | undefined, openingTag: string | undefined, closingTag: string | undefined, indentSize: number | undefined, parameterWrap: boolean | undefined }>}

Based on learnings: "Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions."

🤖 Fix all issues with AI agents
In `@packages/components/src/components/OnClose.js`:
- Around line 71-75: Update the JSDoc for the OnClose component to clearly state
that props.framework is required for framework-specific languages (e.g., when
props.language === 'java' the config is nested) and list acceptable framework
values or behavior; additionally, inside the OnClose function add validation
that checks props.language and props.framework (when language === 'java') and
either throw a descriptive error or render a visible warning instead of
producing an empty <Text> when framework is missing/unknown. Reference: OnClose
component, props.framework, props.language, props.title.
🧹 Nitpick comments (1)
packages/components/src/components/MethodGenerator.js (1)

19-49: Return type may not match runtime behavior.

The @returns annotation specifies { docs: string, logic: string }, but when methodConfig is not provided and methodDocs/methodLogic are undefined, the function returns { docs: undefined, logic: undefined } (lines 32-33 assign directly without defaults).

Suggested fix
-* `@returns` {{ docs: string, logic: string }}
+* `@returns` {{ docs: string | undefined, logic: string | undefined }}

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: 1

🤖 Fix all issues with AI agents
In `@packages/components/src/components/OnClose.js`:
- Around line 99-103: The OnClose component currently calls
resolveCloseConfig(language, framework) and silently returns an empty <Text>
when generateOnCloseCode is undefined, causing framework-specific languages
(e.g., java) to render blank when Connect renders <OnClose language={language}
title={title} /> without a framework; fix by passing the framework through from
the caller and surfacing a visible warning when framework is missing: update the
Connect.js call site to forward framework into <OnClose language={language}
title={title} framework={framework} /> (or the appropriate prop name you use),
and in OnClose (where websocketOnCloseMethod and resolveCloseConfig are used)
replace the silent return with a clear Text warning message (or throw) that
includes the language name and instructs the caller to provide a framework when
resolveCloseConfig(language, framework) returns undefined.

@batchu5
Copy link
Contributor Author

batchu5 commented Jan 28, 2026

@Adi-204 I fixed the lint errors. Can you please review again?

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

lgtm! @derberg can you please take a look.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

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.

please create folloup issue

title: Reusable Components API
weight: 77

@derberg derberg moved this from In Progress to Done in Maintainers work Feb 4, 2026
@derberg
Copy link
Member

derberg commented Feb 4, 2026

/rtm

@asyncapi-bot asyncapi-bot merged commit bd0f36f into asyncapi:master Feb 4, 2026
15 checks passed
@derberg derberg moved this from Done to Archive in Maintainers work Feb 18, 2026
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.

Introduce API generation for components

4 participants

Comments