Skip to content

Support $defs keyword for JSON Schema draft 2019-09+#1913

Open
lahma wants to merge 1 commit intoRicoSuter:masterfrom
lahma:fix/support-defs-keyword-1536
Open

Support $defs keyword for JSON Schema draft 2019-09+#1913
lahma wants to merge 1 commit intoRicoSuter:masterfrom
lahma:fix/support-defs-keyword-1536

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 8, 2026

Summary

  • Support the $defs keyword (JSON Schema draft 2019-09+) in addition to the existing definitions keyword (draft-04/06/07)
  • $defs entries are extracted from ExtensionData after deserialization and merged into the Definitions dictionary
  • References like #/$defs/Foo are resolved by mapping $defs path segments to the Definitions dictionary in the reference resolver
  • When re-serialized, schemas use definitions (normalized to draft-04 format)

Fixes #1536

Changes

  • JsonExtensionObject.cs: Added MergeDefsIntoDefinitions method called during deserialization
  • JsonReferenceResolver.cs: Map $defs path segment to definitions during reference resolution
  • JsonSchemaReferenceUtilities.cs: Added /$defs/ path detection for inline reference replacement

Test plan

  • Schema with $defs and $ref: "#/$defs/..." references resolves correctly
  • $defs entries appear in Definitions dictionary after deserialization
  • Re-serialization uses definitions (not $defs)
  • All 413 existing tests continue to pass

🤖 Generated with Claude Code

Map $defs entries into the Definitions dictionary during deserialization
so that references like '#/$defs/Foo' resolve correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

The schema reference path '#/$defs/.....' has not been resolved.

1 participant