Summary
$dynamicRef values that point to external files (e.g., $dynamicRef: 'other.json#node') currently fall back to unknown in generated TypeScript output.
Why
The bundler (@hey-api/json-schema-ref-parser) only resolves $ref URIs — it fetches external files and inlines them into the bundled spec. $dynamicRef is invisible to the bundler, so external files are never fetched and the anchor is never available for dynamic scope resolution.
What's needed
-
@hey-api/json-schema-ref-parser: Add isExternalDynamic$Ref() check in the crawl phase (resolve-external.ts), mirroring the existing isExternal$Ref() path. Fetch external files referenced by $dynamicRef, parse them, and add them to the $refs cache. The $dynamicRef string itself should be preserved (not rewritten to $ref) so the parser's dynamic scope resolution continues to work.
-
@hey-api/shared (parser): After bundling brings the external schemas inline, resolveDynamicRef() may need to handle cases where the $dynamicRef URI now points to a bundled-in anchor rather than an external one.
Current behavior
# spec.yaml
components:
schemas:
Container:
type: object
properties:
item:
$dynamicRef: 'other.json#node'
// Generated output
export type Container = { item: unknown };
Expected behavior
// After fix
export type Container = { item: Node };
Workaround
Move the referenced schemas into the main spec file under components.schemas and use internal $dynamicRef + $dynamicAnchor instead of external references.
If you need this feature, please upvote this issue with a 👍 reaction.
Summary
$dynamicRefvalues that point to external files (e.g.,$dynamicRef: 'other.json#node') currently fall back tounknownin generated TypeScript output.Why
The bundler (
@hey-api/json-schema-ref-parser) only resolves$refURIs — it fetches external files and inlines them into the bundled spec.$dynamicRefis invisible to the bundler, so external files are never fetched and the anchor is never available for dynamic scope resolution.What's needed
@hey-api/json-schema-ref-parser: AddisExternalDynamic$Ref()check in the crawl phase (resolve-external.ts), mirroring the existingisExternal$Ref()path. Fetch external files referenced by$dynamicRef, parse them, and add them to the$refscache. The$dynamicRefstring itself should be preserved (not rewritten to$ref) so the parser's dynamic scope resolution continues to work.@hey-api/shared(parser): After bundling brings the external schemas inline,resolveDynamicRef()may need to handle cases where the$dynamicRefURI now points to a bundled-in anchor rather than an external one.Current behavior
Expected behavior
Workaround
Move the referenced schemas into the main spec file under
components.schemasand use internal$dynamicRef+$dynamicAnchorinstead of external references.If you need this feature, please upvote this issue with a 👍 reaction.