feat: add support for AsyncAPI 2 and 3 in the split command#2552
feat: add support for AsyncAPI 2 and 3 in the split command#2552tibisabau wants to merge 11 commits intoRedocly:mainfrom
Conversation
🦋 Changeset detectedLatest commit: cb77447 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 |
e9121a4 to
8875719
Compare
|
@tibisabau |
|
@tibisabau |
| messages: | ||
| UserLoggedIn: | ||
| $ref: '#/components/messages/UserLoggedIn' | ||
| operations: |
There was a problem hiding this comment.
@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'There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
| $ref: '#/channels/userSignedup' | |
| $ref: '#/channels/userSignedUp' |
Co-authored-by: Dmytro Anansky <dmytro@redocly.com>
3205cd1 to
4d328bd
Compare
What/Why/How?
What: Added support for AsyncAPI 2.x and 3.x specifications to the
splitcommand, 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:
splitAsyncApiDefinition()orchestrator function to handle both AsyncAPI versionsiterateAsyncApiChannels()to split channels into separate files with proper $ref replacementsiterateAsyncApiOperations()for AsyncAPI 3 operations splittingiterateAsyncApiComponents()to handle component extraction with version-specific logicvalidateDefinitionFileName()to recognize AsyncAPI documentsReference
Resolves #2352
Testing
tests/e2e/split/asyncapi2-basic/asyncapi.yamlandtests/e2e/split/asyncapi3-basic/asyncapi.yamlScreenshots (optional)
N/A - CLI functionality
Check yourself
Security