Skip to content

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

Open
tibisabau wants to merge 11 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 11 commits intoRedocly:mainfrom
tibisabau:feat/add-support-asyncapi23-split

Conversation

@tibisabau
Copy link
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

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: cb77447

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

sendUserSignedup:
action: send
channel:
$ref: '#/channels/userSignedup'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$ref: '#/channels/userSignedup'
$ref: '#/channels/userSignedUp'

@tibisabau tibisabau force-pushed the feat/add-support-asyncapi23-split branch from 3205cd1 to 4d328bd Compare March 26, 2026 20:34
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