Skip to content

docs: rewrite Java template tutorial to AsyncAPI v3#2029

Open
wei123-web wants to merge 4 commits intoasyncapi:masterfrom
wei123-web:docs/update-java-template-v3
Open

docs: rewrite Java template tutorial to AsyncAPI v3#2029
wei123-web wants to merge 4 commits intoasyncapi:masterfrom
wei123-web:docs/update-java-template-v3

Conversation

@wei123-web
Copy link
Copy Markdown

@wei123-web wei123-web commented Mar 25, 2026

Description

Rewrites the "Creating a template – Java" tutorial to use AsyncAPI v3.

Changes made:

  • Updates AsyncAPI document from v2.6.0 to v3.0.0
  • Replaces url: with host: in servers section
  • Migrates TopicFunction to use operations API instead of channels API
  • Renames getTopics to getTopicsFromOperations
  • Updates index.js to use asyncapi.operations().filterByReceive()
  • Updates server URL to use server.host()
  • Fixes duplicated "generated generated" text in output logs

Related issue

Resolves #1828

Summary by CodeRabbit

  • Documentation
    • Updated Java tutorial and examples to AsyncAPI v3.0 format and fixed duplicated console text.
  • New Features
    • Template now generates topic methods from v3 receive operations and captures server info for broker URL generation in the generated client.
  • Bug Fixes
    • Removed an unused import and corrected end-of-file newline handling.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

⚠️ No Changeset found

Latest commit: 285cd92

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b0e94f79-ed28-493a-a49c-ecef01dbb353

📥 Commits

Reviewing files that changed from the base of the PR and between 10e2010 and 50f0052.

📒 Files selected for processing (1)
  • apps/generator/docs/generator-template-java.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/generator/docs/generator-template-java.md

📝 Walkthrough

Walkthrough

Updated the Java template tutorial to AsyncAPI v3: example document, template code, and TopicFunction now use v3 operations and server APIs; fixed duplicate log text and minor imports/newline issues in the tutorial snippets. (≤50 words)

Changes

Cohort / File(s) Summary
Generator Java tutorial
apps/generator/docs/generator-template-java.md
Rewrote examples to AsyncAPI v3: replaced channel-based TopicFunction with operations-based API (TopicFunction({ operations }), getTopicsFromOperations(operations)), switched template to use asyncapi.operations().filterByReceive() and capture const server = asyncapi.server(params.server), changed broker URL interpolation to tcp://${server.host()}, updated example YAML to asyncapi: 3.0.0, removed an unused import, fixed duplicated tutorial log text, and corrected EOF newline marker.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 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: rewriting the Java template tutorial from AsyncAPI v2 to v3, using imperative mood and following Conventional Commits guidelines.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from #1828: updated AsyncAPI document to v3, migrated template code to v3 parser API (operations instead of channels), and ensured consistency with other language tutorials.
Out of Scope Changes check ✅ Passed All changes are directly related to updating the Java template tutorial to AsyncAPI v3, including fixes like removing unused imports and correcting console output duplication, which are ancillary improvements within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@asyncapi-bot
Copy link
Copy Markdown
Contributor

asyncapi-bot commented Mar 25, 2026

🚀 Docs preview deployed
Below link points directly to the generator docs preview. May the force be with you!
https://69d72f1b29518eb8eab8c804--asyncapi-website.netlify.app/docs/tools/generator

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
apps/generator/docs/generator-template-java.md (1)

318-318: Wording drift: this should reference operations, not channels.

Since this section migrates to AsyncAPI v3 operations, “regardless of the number of channels” is misleading here.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/generator/docs/generator-template-java.md` at line 318, The sentence
currently references "channels" but this section is about AsyncAPI v3
operations; update the wording around the `TopicFunction` description to
reference "operations" (or "the number of operations in the AsyncAPI v3
document") instead of "channels" so it accurately reflects that the reusable
component applies regardless of operation count in the asyncAPI v3 document.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/generator/docs/generator-template-java.md`:
- Line 393: BROKER_URL is being set to server.host() which yields "host:port"
but the Paho MQTT client requires a URI with a scheme; update the assignment
that sets the static constant BROKER_URL (and the server.host() usage in the
server configuration) to prepend an appropriate scheme such as "tcp://" (e.g.,
"tcp://" + server.host()) so the value becomes a valid URI like
"tcp://test.mosquitto.org:1883" before it is used by the client.
- Around line 355-357: The template is filtering receive operations which misses
AsyncAPI operations with action: send; update getTopicsFromOperations to use
operations.filterBySend() when generating publish/send methods (replace
operations.filterByReceive() with operations.filterBySend()), and apply the same
change to other occurrences where publish methods are derived (the other places
using operations.filterByReceive() for send-method generation) so generated
TestClient sendTemperatureDrop/Rise methods match the document's action: send
operations.

---

Nitpick comments:
In `@apps/generator/docs/generator-template-java.md`:
- Line 318: The sentence currently references "channels" but this section is
about AsyncAPI v3 operations; update the wording around the `TopicFunction`
description to reference "operations" (or "the number of operations in the
AsyncAPI v3 document") instead of "channels" so it accurately reflects that the
reusable component applies regardless of operation count in the asyncAPI v3
document.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 25edfbe6-b065-444b-9743-ce85e40aeb58

📥 Commits

Reviewing files that changed from the base of the PR and between 9e53861 and 10e2010.

📒 Files selected for processing (1)
  • apps/generator/docs/generator-template-java.md

@derberg derberg self-assigned this Mar 25, 2026
@Adi-204
Copy link
Copy Markdown
Member

Adi-204 commented Apr 9, 2026

/u

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[📑 Docs]: Rewrite “Creating a template – Java” tutorial to use AsyncAPI v3

4 participants