Expand description
Importing repair schemas from JSON Schema documents
Converts a JSON Schema (as a serde_json::Value) into a
TaggedEnumSchema or ObjectSchema, so schemas produced by
schemars, Pydantic, or any other tool can drive fuzzy repair without
hand-written builder code. With the schemars cargo feature enabled,
[TaggedEnumSchema::from_type] / [ObjectSchema::from_type] derive the
repair schema directly from a #[derive(JsonSchema)] type.
§Supported subset (v1)
- Tagged enums:
oneOfwhere every branch carries a common tag property with aconst(or single-elementenum) string value — the shape schemars emits for#[serde(tag = "...")](internally tagged) and#[serde(tag = "...", content = "...")](adjacently tagged). - Keywords:
properties,enum,const,type,items,$ref/$defs(also legacydefinitions), including the Draft 2020-12 sibling-$refcomposition schemars emits for newtype variants.Option<T>-style nullable wrappers (anyOf: [T, {type: null}]) are unwrapped. - Type mapping:
string→FieldKind::String,integer→FieldKind::Integer,number→FieldKind::Number,boolean→FieldKind::Bool,object→FieldKind::Object(recursive), arrays of string enums →FieldKind::EnumArray, arrays of objects →FieldKind::ObjectArray.
§Deliberately unsupported (v1)
- Externally tagged enums (serde’s default representation) and
untagged enums: rejected with an error. Annotate the enum with
#[serde(tag = "...")]so a tag field exists for repair to anchor on. required/defaultcompletion: missing fields are not filled in; the keywords are ignored.- Constructs with no repair semantics (
allOf,patternProperties, tuples viaprefixItems, nestedoneOfon fields, recursive$refcycles) degrade toFieldKind::Anyand are reported asImportWarnings rather than silently dropped.
Structs§
- Import
Warning - A construct in the source JSON Schema that could not be converted.
- Schema
Import - Result of a JSON Schema import: the converted schema plus warnings for
every construct that could not be mapped (degraded to
FieldKind::Any).