Generates Python/Pydantic type definitions for the specified schema and writes them to the specified file. Typesync first “flattens” your schema, creating new aliases for inline types defined within. It then generates the classes, enums, aliases, etc. including serializers and deserializers.

Usage

typesync generate-py --definition <filePathOrPattern> --target <targetEnvironment> --outFile <filePath> --indentation <indentation> --customPydanticBase <classImportPath> --debug <debug>

Options

definition
string
required

The exact path or a Glob pattern to the definition file or files. Each definition file must be a YAML or JSON file containing model definitions.

  • Example single file path: definition/models.json
  • Example Glob pattern: 'definition/**/*.yml'
target
string
required

The target environment for which the types are generated. This option specifies the target SDK and version, ensuring that the output is compatible with the chosen environment. See the list of available targets here.

outFile
string
required

The path to the output file.

customPydanticBase
string

The base class from which all the generated Python models will extend. The base class must extend pydantic.BaseModel and the option must be provided in the format x.y.ModelName. If this option is not provided, the generated models will extend from pydantic.BaseModel.

Example values:

  • custom.MyModel
  • a.b.c.MyCustomModel
undefinedSentinelName
string
default: "UNDEFINED"

The name of the sentinel value used to indicate that a field should be missing from a given object. This is generated as a variable alongside your model definitions.

indentation
int
default: 2

Indentation or tab width for the generated code.

debug
boolean
default: false

Whether to enable debug logs.

Targets