Getting started¶
Prerequisites¶
Make sure you have python >= 3.6 and pip up and running.
$ python --version
Python 3.7.9
$ pip --version
pip 20.2.4 from /home/docs/checkouts/readthedocs.org/user_builds/xsdata/envs/v20.11/lib/python3.7/site-packages/pip (python 3.7)
Warning
In python 3.6 the typing module is flattening subclasses in unions, this may affect how values are converted.
There is no official workaround because it’s not very common, if you like monkey
patching then take a look here typing._remove_dups_flatten()
>>> from dataclasses import dataclass
>>> from typing import Union, get_type_hints
>>>
>>> @dataclass
... class Example:
... value: Union[int, bool, str, float]
...
>>> get_type_hints(Example)
{'value': typing.Union[int, str, float]}
>>> issubclass(bool, int)
True
Install xsData¶
Install xsData package using pip.
pip install xsdata
Verify installation using the cli entry point.
$ xsdata --help
Usage: xsdata [OPTIONS] COMMAND [ARGS]...
xsdata command line interface.
Options:
--version Show the version and exit.
-v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG
--help Show this message and exit.
Commands:
generate* Convert schema definitions to code.
download Download a schema or a definition locally with all its...
init-config Create or update a configuration file.