Registry / serialization / xsdata-pydantic

xsdata-pydantic

JSON →
library24.5pypypiunverified

xsdata-pydantic is a plugin for xsdata that generates Pydantic models from XML Schema (XSD) documents. It provides a code generator producing Python classes with Pydantic v1 or v2 support, data binding, and serialization. The current version is 24.5, compatible with Python >=3.8 and xsdata >=22.10. Release cadence is irregular.

pip install xsdata-pydantic
INSTALL
IMPORT
SIG · XSDATA-PYDANTIC
X
xsdata-pydantic
serializationpythonv24.5
Install
3.5s avg
Import
Disk
28MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v24.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 30.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.5s · import 0.000s · 30MB
28MB installed
● package 28MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PydanticExtension
from xsdata_pydantic import PydanticExtension
from xsdata_pydantic import PydanticExtension

Install the plugin, generate Pydantic models using xsdata CLI with the extension, then parse and serialize XML data.

from xsdata_pydantic import PydanticExtension from xsdata.formats.dataclass.serializers import XmlSerializer from xsdata.formats.dataclass.parsers import XmlParser # Generate models from XSD using CLI or code generator # Example: xsdata my-schema.xsd --package mypackage --extension PydanticExtension # After generation, use parser and serializer parser = XmlParser() serializer = XmlSerializer()
xsdata --version
Debug
Known issues
breakingIn version 24.x, Pydantic v2 is the default. If you need Pydantic v1, you must explicitly set the extension with PydanticV1Extension.
fix
Use 'from xsdata_pydantic import PydanticV1Extension' and pass it as the extension.
affects: >=24.0
gotchaThe generated models are dataclasses with Pydantic validation. They cannot be directly used with raw Pydantic BaseModel methods like .model_dump_json(). Use the xsdata XmlSerializer instead.
fix
Use XmlSerializer from xsdata to serialize to XML, or convert to dict/list manually.
affects: all
deprecatedPython 3.8 support will be dropped in a future release. Ensure you use Python 3.9+ for new projects.
fix
Upgrade to Python 3.9 or later.
affects: >=24.5
Upgrade
Version history
24.5latest on PyPI · released May 8, 2024
Audit
Dependencies
xsdatarequiredCore library for XML data binding and code generation.
pydanticrequiredRequired for model generation and runtime validation.
Agent activity
61 hits · last 30 days
node
56
OpenAI (training)
1
Resources
xsdata-pydantic — pip install xsdata-pydantic · libregistry