Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

vigonotion/xsd-to-vol

Repository files navigation

xsd-to-vol

ci Code style: black Open Issues Release PyPI version

Convert XML Schema Definition files to voluptuous schemas.

Get it on PyPi:

pip install xsd-to-vol

Binary file usage

Basic usage:

xml-to-vol -i schema.xsd -o schema.py

Basic pipe usage:

cat schema.xsd | xml-to-vol > schema.py

Pipe through black formatter:

cat schema.xsd | xsd-to-vol | black - > schema.py

Advanced piping example with curl:

curl -s https://api-test.geofox.de/gti/public/geofoxThinInterfacePublic.xsd 2>&1 | xsd-to-vol | black - > schema.py

You can also mix input/output files and stdin/stdout.

Library usage

You can also use the xml_to_vol method to convert your schema:

from xsd_to_vol import xsd_to_vol

with open("schema.xsd", 'r') as schema_file:
    xsd = schema_file.read()
    print(xsd_to_vol(xsd))

To Do

While the generation should work for most xsd files, there are some features I'd like to have in future versions:

  • Only include used imports: Currently all possible voluptuous requirements are imported. The required imports can be determined.
  • Tests: Gather different xsd schemas and build pytests to test the generation.
  • Automatic code formatting: Run black over the code (without piping).

Contributions are welcome!

If you want to contribute to this, please read the Contribution guidelines

About

Convert XML Schema Definitions to Voluptuous schemas.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages