fix(cli): resolve external JSON references in AsyncAPI specs #11773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes external JSON references (
$ref) in AsyncAPI specifications not being resolved. Previously, AsyncAPI specs with references like$ref: "./schemas/file.yml#/Schema"would fail to resolve, resulting in empty messages and missing types.Link to Devin run: https://app.devin.ai/sessions/9fadf9f4b75a485db4df87fba1fa910d
Requested by: [email protected]
Changes Made
resolveLocalFileRefsfunction inloadAsyncAPI.tsto resolve local file references./schemas/file.yml#/Schema) while preserving URL references (http://,https://) for the AsyncAPI converter to handle#/SpeakV1Encoding) to extract specific schemas from referenced filesUpdates since last revision
Initially attempted to use
@redocly/openapi-core'sbundlefunction (same as OpenAPI), but this resolved URL references too aggressively, breaking the AsyncAPI converter which expects URL refs to retain their$refproperty. Switched to a custom local-file-only resolver that preserves URL references.Testing
asyncapi-json-refs(from PR chore(cli): add test for AsyncAPI with JSON references to external files #11770) now passes with resolved referencesurl-referencetest continues to pass (URL refs preserved correctly)plantUpdateschannel now has messages (previously empty[])SpeakV1Encodingtype is now included in typesChannelsPlantUpdatesSubscribeEncodingenum properly extractedpnpm run check)Review Checklist
resolveLocalFileRefshandles edge cases correctly (missing files, invalid JSON pointers)