fix: resolve $refs and validate AsyncAPI 3 Multi Format Schema Object - #3045
Conversation
🦋 Changeset detectedLatest commit: 4bb46f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Performance Benchmark (Lower is Faster)
|
|
📦 A new experimental 🧪 version v0.0.0-snapshot.1787151744 of Redocly CLI has been published for testing. Install with NPM: npm install @redocly/cli@0.0.0-snapshot.1787151744 |
a423eb6 to
4bb46f2
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4bb46f2. Configure here.
| additionalProperties: (value: unknown) => { | ||
| return isPlainObject(value) && 'schema' in value ? 'MultiFormatSchema' : 'Schema'; | ||
| }, | ||
| }; |
There was a problem hiding this comment.
NamedSchemas pollutes Schema definitions
Low Severity
NamedSchemas is now a Schema-vs-MultiFormatSchema discriminator for components.schemas, but the shared draft-7 Schema type still points definitions at the string NamedSchemas. In AsyncAPI 3 that makes nested JSON Schema definitions accept Multi Format shapes, even though those entries must remain plain Schema Objects.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4bb46f2. Configure here.


What/Why/How?
AsyncAPI 3 allows two shapes for
headers,payload, andcomponents.schemas: a Schema Object, or a Multi Format Schema Object that holds the schema inschemaand its format inschemaFormat.The type definitions used an anonymous node type for the multi-format shape. Two defects followed:
resolveTypenormalizes only types that passisNamedType, so it returned the anonymous type unchanged. Theschemaproperty kept the raw string'Schema'.scalarand stops. It never enteredschema, so the bundler never found the$refinside it.Found in https://github.com/Redocly/redocly/pull/26390
Reference
https://www.asyncapi.com/docs/reference/specification/v3.0.0#multiFormatSchemaObject
https://www.asyncapi.com/docs/reference/specification/v3.0.0#messageObject
https://www.asyncapi.com/docs/reference/specification/v3.0.0#componentsObject
Testing
Screenshots (optional)
Check yourself
Security
Note
Low Risk
Type-system fix for AsyncAPI 3 schema walking only; no auth, data, or runtime behavior outside bundling/validation.
Overview
Fixes
bundle(and walking/validation) skipping$refs inside AsyncAPI 3 Multi Format Schema Objects.Anonymous inline types for the
{ schema, schemaFormat }shape were not named, soresolveTypeleftschemaas a raw string and the walker treated the node as a scalar. This adds a namedMultiFormatSchematype and uses it forheaders,payload, message-traitheaders, andcomponents.schemaswhen the value has aschemaproperty (plain Schema Objects still work). An e2e bundle fixture covers multi-format, default-format, and plain schema cases.Reviewed by Cursor Bugbot for commit 4bb46f2. Bugbot is set up for automated code reviews on this repo. Configure here.