Skip to content

Add pre-dereference normalization for annotation siblings in files#683

Open
LudaThomas wants to merge 2 commits into
bcherny:masterfrom
LudaThomas:master
Open

Add pre-dereference normalization for annotation siblings in files#683
LudaThomas wants to merge 2 commits into
bcherny:masterfrom
LudaThomas:master

Conversation

@LudaThomas

Copy link
Copy Markdown

// JSON Schema 2019-09 allows annotation siblings next to $ref. When such
// siblings are present, json-schema-ref-parser produces a fresh merged object
// for the $ref, which breaks the referential equality the parser relies on
// to emit a named reference instead of inlining the target type. By wrapping
// the $ref in a single-member allOf before dereferencing, the dereferenced
// pointer keeps its identity and the annotations remain on the wrapper, where
// they can attach as a property-level JSDoc comment.

see #363

LudaThomas added 2 commits May 9, 2026 11:19
The lift transform only ran on the root input schema, so sibling-
annotated  inside files loaded by json-schema-ref-parser still
merged and produced suffixed duplicates (Range2, Hyperparameters1,
etc.) when the root schema 'd across files.
Wrap the JSON and YAML parser plugins so the transform runs on every
loaded file as it's parsed.
@loyd

loyd commented May 15, 2026

Copy link
Copy Markdown

@LudaThomas, I just want to say "thank you". Even if the PR won't be merged, it's clear how to modify the JSON schema to avoid this problem.

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.

2 participants