Skip to content

Typing Customization

Control Python annotation syntax, collection types, imports, and type mappings.

Options are grouped from shared CLI metadata and link back to their generated reference sections.

Groups

Group Options Description
Imports 2 Generated imports and type-checking import behavior.
Collection Types 8 Collection and tuple/set generation.
Type Alias 4 TypeAlias and root-model alias output.
Type Mapping 20 Scalar, date/time, and custom type mapping.
Type Syntax 3 Modern annotation syntax and Annotated usage.

Imports

Generated imports and type-checking import behavior.

Option Description
--disable-future-imports Prevent automatic addition of future imports in generated code.
--import-overrides Override modules for generated imports by symbol name.

Collection Types

Collection and tuple/set generation.

Option Description
--no-use-standard-collections Use typing.Dict/List instead of built-in dict/list for container types.
--use-generic-container-types Use generic container types (Sequence, Mapping) for type hinting.
--use-standard-collections Use built-in dict/list instead of typing.Dict/List.
--use-tuple-for-closed-arrays Generate tuple types for positional arrays that no other item can follow.
--use-tuple-for-fixed-items Generate tuple types for arrays with items array syntax.
--use-tuple-for-fixed-length-arrays Generate tuple types for homogeneous fixed-length arrays.
--use-unique-items-as-set Generate set types for arrays with uniqueItems constraint.
--use-unique-items-as-set-by-value Write a uniqueItems set only where its final items hash by value.

Type Alias

TypeAlias and root-model alias output.

Option Description
--use-plain-alias-for-recursive-models Write the type alias of a model that names itself as a plain alias in Pydantic o...
--use-root-model-type-alias Generate RootModel as type alias format for better mypy support.
--use-type-alias Use TypeAlias instead of root models for type definitions (experimental).
--use-type-alias-type Use runtime TypeAliasType objects for aliases before Python 3.12 (experimental).

Type Mapping

Scalar, date/time, and custom type mapping.

Option Description
--output-date-class Specify date class type for date schema fields.
--output-datetime-class Specify datetime class type for date-time schema fields.
--read-unevaluated-properties Read a schema-valued unevaluatedProperties as additionalProperties.
--strict-types Enable strict type validation for specified Python types.
--type-mappings Override default type mappings for schema formats.
--type-overrides Replace schema model types with custom Python types via JSON mapping.
--type-overrides-replace-whole-type Make every --type-overrides value of a field replace the field's whole type.
--use-bytes-for-content-media-type Type an OpenAPI string with a contentMediaType and no contentEncoding as `by...
--use-decimal-for-multiple-of Generate Decimal types for fields with multipleOf constraint.
--use-decimal-in-field-forms Write Decimal for a number with multipleOf in the field forms too.
--use-encoded-str-for-constrained-base64 Check the constraints of a format: byte string on its base64 text in the field...
--use-object-type Use object instead of Any for unspecified object and array values.
--use-pendulum Use pendulum types for date, time, and duration fields.
--use-single-dict-for-object-maps Type an object map as one dict instead of a union of dicts.
--use-standard-primitive-types Use Python standard library types for string formats instead of str.
--use-strict-str-for-base64 Make a format: byte string strict under --strict-types str.
--use-typed-map-values-beside-other-types Type the map values of type arrays that list object beside other types.
--use-typed-nullable-map-values Type the values of nullable maps as their schemas say instead of Any.
--use-x-python-import-for-every-ref Type every reference to a schema with x-python-import by the class it imports.
--use-x-python-type-as-written Write a field's x-python-type as given: unions of every spelling and container...

Type Syntax

Modern annotation syntax and Annotated usage.

Option Description
--no-use-union-operator Use Union[X, Y] / Optional[X] instead of X | Y union operator.
--use-annotated Use typing.Annotated for Field() with constraints.
--use-union-operator Use | operator for Union types (PEP 604).