Repository navigation
Conversation
Move completion, hover and validation to the v10 compileSchema API. v10 keeps sibling keywords next to $ref, so a $ref combined with a oneOf of consts now offers those values as completions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
json-schema-library validates "if" against a copy of the validation path so the nodes it evaluates aren't recorded. The path holds every node visited so far and is never trimmed, so each "if" costs time proportional to everything validated before it and validation is quadratic in document size. Schemas that select definitions with if/then took ~30s on a 380KB document and crashed the tab at 2MB. v10 and v11 are both affected. Compile schemas with drafts whose "if" validator uses the shared path and truncates it afterwards, which discards the same entries without the copy and keeps the dynamic scope for $dynamicRef and $recursiveRef. All features now compile through utils/compile-schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: b941cb5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for codemirror-json-schema ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
json-schema-library v10 validators return errors only, and its unevaluatedProperties re-runs "if" to find the evaluated branch, so the wrapper's results match the library's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
json-schema-library resolves a $ref by replacing the node with its
target and dropping sibling keywords, the draft 4/7 behaviour, even when
the schema declares draft 2020-12. That discards constructs like
{ "$ref": "#/$defs/key", "oneOf": [ { "const": "..." }, ... ] }
where the oneOf carries the real constraint, so no value completions
are offered and the constraint isn't validated.
Normalize schemas on entry into the equivalent, draft-agnostic
{ "allOf": [ { "$ref": ... }, { ...siblings } ] }. Annotation keywords
(title, description, ...) stay at the top level so property metadata is
preserved. This replaces the getRawSchemaForPointer workaround, which
only followed object properties and broke on a root-level $ref and on
array item pointers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drafts 04, 06 and 07 ignore keywords next to $ref, so rewriting them into an allOf changed what those schemas accept. Skip schemas, and nested resources, whose $schema declares one of those drafts, matching how json-schema-library picks a draft. Schemas without $schema keep being normalized, as the library treats them as 2020-12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
samlown
force-pushed
the
upstream-pr/ref-sibling-keywords
branch
from
October 27, 2026 14:57
f94e9c1 to
b941cb5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Builds on #176. This branch contains #176's commits, so only the last two commits (ecd1338, b941cb5) are new here. Once #176 is merged, this diff will shrink to those commits.
Problem
Since draft 2019-09,
$refcombines with the keywords next to it. json-schema-library resolves a$refby replacing the node with its target, which drops those keywords even when the schema declares draft 2020-12. A schema like{ "$ref": "#/$defs/key", "oneOf": [{ "const": "a" }, { "const": "b" }] }loses its
oneOfonce resolved, soaandbaren't offered as completions.Fix
Schemas are normalized on entry (
updateSchemaandstateExtensions) into the equivalent, draft-agnostic form:{ "allOf": [{ "$ref": "#/$defs/key" }, { "oneOf": [...] }] }Every draft handles this form the same way, and the existing
allOfcompletion branch picks it up. Annotation keywords such astitleanddescriptionstay at the top level, so property metadata is preserved.Schemas whose
$schemadeclares draft-04, -06 or -07 are left unchanged, because those drafts ignore keywords next to$ref. A nested$schemaapplies to its subschemas. Schemas without$schemaare normalized, because json-schema-library treats them as 2020-12.The normalizer only follows schema-bearing keywords (
src/utils/schema-walk.ts):const,enum,defaultorexamples.properties, it treats every entry as a schema, so a property namedconstis still normalized.This replaces the
getRawSchemaForPointerworkaround, which only followed objectpropertiesand failed for a root-level$refand for array item pointers.Tests
$ref+oneOffixture (an e-invoicing addons list).pnpm test(144 tests) andpnpm tscpass.🤖 Generated with Claude Code