Multi-draft validation
jsonschema now validates Draft 2019-09, Draft-07, Draft-06, and Draft-04 in addition to Draft 2020-12, selected automatically from each schema's $schema. When a schema omits $schema it defaults to Draft 2020-12, so existing code is unaffected.
// Opt a $schema-less schema into a specific draft:
compiler := jsonschema.NewCompiler().SetDefaultDialect(jsonschema.Draft7)Each dialect's keyword semantics are honored — Draft-04 id, boolean exclusiveMinimum/exclusiveMaximum, dependencies (→ dependentRequired/dependentSchemas), tuple items + additionalItems, and Draft 2019-09 $recursiveRef/$recursiveAnchor (mapped to dynamic refs). Behavior is verified against the official JSON Schema Test Suite for all five drafts.
New API
Dialecttype with constantsDraft202012,Draft201909,Draft7,Draft6,Draft4(*Compiler).SetDefaultDialect(Dialect)— dialect used when a schema has no$schema(defaultDraft202012)(*Schema).Dialect()— the resolved dialect of a compiled schemaSchema.CommentandSchema.Vocabularytyped fields for$commentand$vocabulary
Dialect-aware keyword recognition
A keyword is recognized only under the dialects that define it; anything else is preserved verbatim in Schema.Extra (with SetPreserveExtra(true)) and ignored for validation. $comment and $vocabulary are modeled as fields and round-trip cleanly.
Performance
The compile/parse path was reworked: schema objects decode in a single pass, the dialect walk allocates nothing, and unknown keywords are decoded lazily. newSchema allocations dropped ~73% and bytes ~55% on a representative schema.
Compatibility
Purely additive. Default Draft 2020-12 validation is unchanged for valid schemas, and the Schema.Extra contract matches v0.8.x. No breaking changes.
Full Changelog: https://github.com/kaptinlin/jsonschema/compare/v0.8.1...v0.9.0