Code Generator¶
CLI Entry Point¶
$ xsdata --help
Usage: xsdata [OPTIONS] SOURCES...
Convert schema definitions to code.
SOURCES can be one or more files or directories or urls.
Options:
--package TEXT Target Package [required]
--output [pydata|plantuml] Output Format
--print Preview the resulting classes.
--version Show the version and exit.
-v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG
--help Show this message and exit.
SOURCES¶
You can pass a list of definitions or a directory which includes the xml schemas you want to process.
$ xsdata amadeus/schemas --package amadeus.models
$ xsdata air_v48_0/AirReqRsp.xsd rail_v48_0/RailReqRsp.xsd --package travelport.models
$ xsdata http://www.gstatic.com/localfeed/local_feed.xsd --package feeds --print
Package¶
The package option defines where the target module(s) will be created inside the current working directory.
If the main xsd has any parent include or import you should adjust the target package.
Example
Output directory
./api/models
Main xsd
./api/air/AirReqRsp.xsd
that includes../common/CommonReqRsp.xsd
Adjust the package from
api.models
toapi.models.air
because the generator has to also create thecommon.common_req_rsp
module.
Output¶
The output option changes the generation format.
pydata
: Python lib dataclassesplantuml
: PlantUML class diagram
Verbosity¶
The verbosity option changes what messages will be printed.
Available options: CRITICAL
, ERROR
, WARNING
, INFO
or DEBUG
Print¶
The print flag overwrites the verbosity level to Error and print to stdOut the output result without writing to the target file.
Examples
Check the Demos and the samples repo for more ✨✨✨