Skip to content

feat: Add AsyncAPI support in the stats command#2553

Open
tibisabau wants to merge 3 commits intoRedocly:mainfrom
tibisabau:feat/add-asyncapi-support-stats
Open

feat: Add AsyncAPI support in the stats command#2553
tibisabau wants to merge 3 commits intoRedocly:mainfrom
tibisabau:feat/add-asyncapi-support-stats

Conversation

@tibisabau
Copy link

What/Why/How?

Added AsyncAPI 2.x and 3.x support to the stats command to provide statistics for AsyncAPI documents, similar to existing OpenAPI support. The stats command now counts channels, operations, schemas, references, tags, parameters, and external docs for AsyncAPI specifications.

Why: Since AsyncAPI support was added for lint and bundle commands, the stats command should support it as well for consistency and completeness.

How: Extended the Stats visitor in packages/core/src/rules/other/stats.ts to handle AsyncAPI-specific node types (ChannelMap, NamedChannels, NamedOperations) and map them to appropriate metrics (channels → pathItems, operations → operations).

Reference

Closes #2353.

Testing

  • Added 3 new E2E test cases covering AsyncAPI 2.x and 3.x stats in stylish and JSON formats
  • All tests pass successfully with generated snapshots
  • Verified stats output for both AsyncAPI versions:
    • AsyncAPI 2.x: 4 channels, 4 operations, 18 references, 17 schemas, 12 external docs, 11 tags
    • AsyncAPI 3.x: 1 channel, 1 operation, 2 references

Screenshots (optional)

N/A

Check yourself

  • Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • All new/updated code is covered by tests
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@tibisabau tibisabau requested review from a team as code owners February 10, 2026 15:38
@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: d1b8913

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/openapi-core Major
@redocly/cli Major
@redocly/respect-core Major

Not sure what this means? Click here to learn what changesets are.

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

Co-authored-by: Dmytro Anansky <dmytro@redocly.com>
ChannelMap: {
Channel: {
leave() {
statsAccumulator.pathItems.total++;
Copy link
Contributor

Choose a reason for hiding this comment

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

PathItem in OAS is not quite the same as Channel in AsyncAPI, although they serve analogous purposes in their respective specifications.
Have you considered a different accumulator options? Like maybe have a separate collector and tune the output with a different label, like Channels?

@@ -0,0 +1,15 @@
🚗 References: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see 3 refs in your file, but snapshot has only 2 reported references.

      UserSignedUp:
        $ref: '#/components/messages/UserSignedUp'
operations:
  sendUserSignedup:
    action: send
    channel:
      $ref: '#/channels/userSignedup'
    messages:
      - $ref: '#/channels/userSignedup/messages/UserSignedUp'

},
},
},
// AsyncAPI 3.x support
Copy link
Contributor

@DmitryAnansky DmitryAnansky Feb 13, 2026

Choose a reason for hiding this comment

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

Have you considered a different implementation approach using detectSpec with separate stats handlers for each specification? This would help to cleanly separate the concepts of different specifications.
In case specs related, e.g. async2/async3, some implementation can be reused/extended.

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.

Add AsyncAPI support in the stats command

2 participants