pyxsd.integrations.pydantic¶
Generate standalone Pydantic models and typed snapshots of bound XML.
Install pyxsd[pydantic]. Models validate the projected data contract;
whole-document XML validation remains Document.revalidate().
Classes¶
A compiled-schema-scoped registry of generated Pydantic models. |
Functions¶
|
Remove the internal |
|
Create a model registry without requiring instance XML. |
Module Contents¶
- pyxsd.integrations.pydantic.clean_field_schema(schema)¶
Remove the internal
Noneplaceholder from one field schema.A missing optional non-nillable field has an internal
Nonedefault in the model, but that is not a nullable input/default in the JSON Schema contract. XSD and RELAX NG schema hooks share this exact cleanup.
- class pyxsd.integrations.pydantic.ModelSet(schema)¶
A compiled-schema-scoped registry of generated Pydantic models.
- Parameters:
schema (pyxsd.schema.Schema)
- schema¶
- model_for(*, element, path=())¶
Resolve a global declaration or an unambiguous local declaration path.
- from_document(document, *, revalidate=False)¶
Snapshot a bound document; request fresh XML validation explicitly.
- Parameters:
document (pyxsd.document.Document)
revalidate (bool)
- Return type:
pydantic.BaseModel
- pyxsd.integrations.pydantic.models(schema: pyxsd.schema.Schema) ModelSet¶
- pyxsd.integrations.pydantic.models(schema: pyxsd.relaxng.schema.RelaxNGSchema) pyxsd.relaxng.pydantic_adapter.RelaxNGModelSet
Create a model registry without requiring instance XML.
A compiled XSD schema still returns the existing
ModelSet. A compiled RELAX NG schema returns its route registry; the RELAX NG adapter is imported lazily so XSD-only use never imports RELAX NG projection code.