Skip to content

feat: add support for AsyncAPI 2 and 3 in the split command#2552

Open
tibisabau wants to merge 15 commits intoRedocly:mainfrom
tibisabau:feat/add-support-asyncapi23-split
Open

feat: add support for AsyncAPI 2 and 3 in the split command#2552
tibisabau wants to merge 15 commits intoRedocly:mainfrom
tibisabau:feat/add-support-asyncapi23-split

Conversation

@tibisabau
Copy link
Copy Markdown
Contributor

What/Why/How?

What: Added support for AsyncAPI 2.x and 3.x specifications to the split command, which previously only supported OpenAPI 3.x.

Why: To enable users to split AsyncAPI definition files into modular directory structures, similar to the existing OpenAPI functionality. This addresses issue #2352.

How:

  • Extended type definitions to include AsyncAPI 2 and 3 component names (schemas, messages, parameters, channels, operations, etc.)
  • Implemented splitAsyncApiDefinition() orchestrator function to handle both AsyncAPI versions
  • Added iterateAsyncApiChannels() to split channels into separate files with proper $ref replacements
  • Implemented iterateAsyncApiOperations() for AsyncAPI 3 operations splitting
  • Created iterateAsyncApiComponents() to handle component extraction with version-specific logic
  • Enhanced spec detection in validateDefinitionFileName() to recognize AsyncAPI documents

Reference

Resolves #2352

Testing

  • Created test fixtures: tests/e2e/split/asyncapi2-basic/asyncapi.yaml and tests/e2e/split/asyncapi3-basic/asyncapi.yaml
  • Ran unit test suite
  • Manual verification: Successfully split both AsyncAPI 2 and 3 documents into proper directory structures with correct $ref resolution
  • TypeScript compilation passed with no errors
  • Code formatted with Prettier

Screenshots (optional)

N/A - CLI functionality

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:09
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: ac4ad1b

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

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

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

@tibisabau tibisabau force-pushed the feat/add-support-asyncapi23-split branch from e9121a4 to 8875719 Compare March 13, 2026 19:14
@tibisabau tibisabau changed the title feat: Add support for AsyncAPI 2 and 3 in the split command feat: add support for AsyncAPI 2 and 3 in the split command Mar 13, 2026
@tibisabau tibisabau requested a review from DmitryAnansky March 13, 2026 19:32
@DmitryAnansky
Copy link
Copy Markdown
Contributor

@tibisabau
Could you please consider adding happy-path unit tests for the newly added functions?
Alternatively, we could loosen the test coverage requirements for now.

@tibisabau tibisabau requested a review from DmitryAnansky March 23, 2026 19:19
@tibisabau tibisabau requested a review from DmitryAnansky March 24, 2026 07:59
@DmitryAnansky
Copy link
Copy Markdown
Contributor

@tibisabau
Thanks for adding the e2e examples — they look great!
Could you please add one more e2e example with a more complex structure to help verify that it works well with more advanced specs?

messages:
UserLoggedIn:
$ref: '#/components/messages/UserLoggedIn'
operations:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tibisabau
Could you please review the splitted result for operations.
Seems like there is an issue, currently the command produced refs that can't be resolved.
I tested on your complex example and it works well for channels and components, but operations seems to be broken.
e.g. =>

action: receive
channel:
  $ref: '#/channels/userLoggedIn'
messages:
  - $ref: '#/channels/userLoggedIn/messages/UserLoggedIn'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did it with
npm run cli split async3_complex.yaml -- --out-dir=result_split
and you can see with the Redocly VSCode extension or lint results that reference can't be resolved:
npm run cli lint result_split/asyncapi.yaml

@tibisabau tibisabau force-pushed the feat/add-support-asyncapi23-split branch from 3205cd1 to 4d328bd Compare March 26, 2026 20:34
@DmitryAnansky
Copy link
Copy Markdown
Contributor

@tibisabau
Thank you for fixing the issue related to splitted operations.
Could you please also check other defined component objects in Async?

I was able to find similar issues when I make changes to the complex example( add other component objects) related to :

  • securitySchemes
  • servers
    ...etc

Please check other components and update your complex example.

@DmitryAnansky
Copy link
Copy Markdown
Contributor

DmitryAnansky commented Mar 31, 2026

@tibisabau
I’ve found another issue with the Async split, related to the replies component object.
It appears to have a similar problem when it’s split.

  replies:
    DeviceCommandReply:
      address:
        $ref: '#/components/replyAddresses/DeviceCommandReplyAddress'
      channel:
        $ref: '#/channels/deviceCommandReply'
      messages:
        - $ref: '#/channels/deviceCommandReply/messages/CommandResponse'

Splitted file have unresolved references for channels and messages:

address:
  $ref: ../replyAddresses/DeviceCommandReplyAddress.yaml
channel:
  $ref: '#/channels/deviceCommandReply'
messages:
  - $ref: '#/channels/deviceCommandReply/messages/CommandResponse'

Could you please take a look, and add this to the complex example test sample.
Thank you.

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.

Support AsyncAPI 3 (and if possible 2) in the split command

3 participants