feat: Add AsyncAPI support in the stats command#2553
feat: Add AsyncAPI support in the stats command#2553tibisabau wants to merge 3 commits intoRedocly:mainfrom
Conversation
🦋 Changeset detectedLatest commit: d1b8913 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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++; |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
What/Why/How?
Added AsyncAPI 2.x and 3.x support to the
statscommand 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.tsto handle AsyncAPI-specific node types (ChannelMap,NamedChannels,NamedOperations) and map them to appropriate metrics (channels → pathItems, operations → operations).Reference
Closes #2353.
Testing
Screenshots (optional)
N/A
Check yourself
Security