You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| [Model Shape](#model-shape) | 6 | Output model family and compatibility targets. |
28116
+
| [Root Model](#root-model) | 4 | Root model creation, collapse, and alias behavior. |
28117
+
28118
+
## Model Naming {#model-naming}
28119
+
28120
+
Class names, suffixes, prefixes, and duplicate-name behavior.
28121
+
28122
+
| Option | Description |
28123
+
|--------|-------------|
28124
+
| [`--allow-leading-underscore-class-name`](../model-customization.md#allow-leading-underscore-class-name) | Allow an explicitly specified root class name to start with an underscore. |
28125
+
| [`--class-name`](../model-customization.md#class-name) | Override the auto-generated class name with a custom name. |
28126
+
| [`--class-name-affix-scope`](../model-customization.md#class-name-affix-scope) | Control which classes receive the prefix/suffix. |
28127
+
| [`--class-name-prefix`](../model-customization.md#class-name-prefix) | Add a prefix to all generated class names. |
28128
+
| [`--class-name-suffix`](../model-customization.md#class-name-suffix) | Add a suffix to all generated class names. |
28129
+
| [`--duplicate-name-suffix`](../model-customization.md#duplicate-name-suffix) | Customize suffix for duplicate model names. |
28130
+
| [`--model-name-map`](../model-customization.md#model-name-map) | Rename generated model classes from a JSON mapping. |
28131
+
| [`--naming-strategy`](../model-customization.md#naming-strategy) | Use parent-prefixed naming strategy for duplicate model names. |
28132
+
| [`--parent-scoped-naming`](../model-customization.md#parent-scoped-naming) | Namespace models by their parent scope to avoid naming conflicts. |
28133
+
28134
+
## Model Reuse {#model-reuse}
28135
+
28136
+
Schema deduplication and shared generated modules.
28137
+
28138
+
| Option | Description |
28139
+
|--------|-------------|
28140
+
| [`--collapse-reuse-models`](../model-customization.md#collapse-reuse-models) | Collapse duplicate models by replacing references instead of inheritance. |
28141
+
| [`--reuse-model`](../model-customization.md#reuse-model) | Reuse identical model definitions instead of generating duplicates. |
28142
+
| [`--reuse-scope`](../model-customization.md#reuse-scope) | Scope for model reuse detection (root or tree). |
28143
+
| [`--shared-module-name`](../general-options.md#shared-module-name) | Customize the name of the shared module for deduplicated models. |
28144
+
28145
+
## Model Shape {#model-shape}
28146
+
28147
+
Output model family and compatibility targets.
28148
+
28149
+
| Option | Description |
28150
+
|--------|-------------|
28151
+
| [`--base-class`](../model-customization.md#base-class) | Specify a custom base class for generated models. |
28152
+
| [`--base-class-map`](../model-customization.md#base-class-map) | Specify different base classes for specific models via JSON mapping. |
28153
+
| [`--output-model-type`](../model-customization.md#output-model-type) | Select the output model type (Pydantic v2, Pydantic v2 dataclass, dataclasses, T... |
28154
+
| [`--target-pydantic-version`](../model-customization.md#target-pydantic-version) | Target Pydantic version for generated code compatibility. |
28155
+
| [`--target-python-version`](../model-customization.md#target-python-version) | Target Python version for generated code syntax and imports. |
28156
+
| [`--use-generic-base-class`](../model-customization.md#use-generic-base-class) | Generate a shared base class with model configuration to avoid repetition (DRY). |
28157
+
28158
+
## Root Model {#root-model}
28159
+
28160
+
Root model creation, collapse, and alias behavior.
28161
+
28162
+
| Option | Description |
28163
+
|--------|-------------|
28164
+
| [`--collapse-root-models`](../model-customization.md#collapse-root-models) | Inline root model definitions instead of creating separate wrapper classes. |
28165
+
| [`--collapse-root-models-name-strategy`](../model-customization.md#collapse-root-models-name-strategy) | Select which name to keep when collapsing root models with object references. |
28166
+
| [`--skip-root-model`](../model-customization.md#skip-root-model) | Skip generation of root model when schema contains nested definitions. |
| [`--custom-template-dir`](../template-customization.md#custom-template-dir) | Use custom Jinja2 templates for model generation. |
28195
+
| [`--extra-template-data`](../template-customization.md#extra-template-data) | Pass custom template variables via inline JSON or a JSON file path. |
28196
+
| [`--validators`](../template-customization.md#validators) | Add custom field validators to generated Pydantic v2 models. |
28197
+
28198
+
## Generated Output {#generated-output}
28199
+
28200
+
Generated file headers and reproducible output.
28201
+
28202
+
| Option | Description |
28203
+
|--------|-------------|
28204
+
| [`--class-decorators`](../template-customization.md#class-decorators) | Add custom decorators to generated model classes. |
28205
+
| [`--custom-file-header`](../template-customization.md#custom-file-header) | Add custom header text to the generated file. |
28206
+
| [`--custom-file-header-path`](../template-customization.md#custom-file-header-path) | Add custom header content from file to generated code. |
28207
+
| [`--disable-timestamp`](../template-customization.md#disable-timestamp) | Disable timestamp in generated file header for reproducible output. |
28208
+
| [`--enable-command-header`](../template-customization.md#enable-command-header) | Include command-line options in file header for reproducibility. |
28209
+
| [`--enable-generated-header-marker`](../template-customization.md#enable-generated-header-marker) | Include the @generated marker in file header for generated-code tooling. |
28210
+
| [`--enable-version-header`](../template-customization.md#enable-version-header) | Include tool version information in file header. |
28211
+
28212
+
## Imports {#imports}
28213
+
28214
+
Generated imports and type-checking import behavior.
| [`--no-use-type-checking-imports`](../template-customization.md#no-use-type-checking-imports) | Keep generated model imports available at runtime when using Ruff fixes. |
28220
+
| [`--use-exact-imports`](../template-customization.md#use-exact-imports) | Import exact types instead of modules. |
28221
+
| [`--use-type-checking-imports`](../template-customization.md#use-type-checking-imports) | Allow Ruff to move typing-only imports into TYPE_CHECKING blocks. |
28222
+
28223
+
## Output Formatting {#output-formatting}
28224
+
28225
+
Formatter selection, quote style, and string wrapping.
| [`--custom-formatters-kwargs`](../template-customization.md#custom-formatters-kwargs) | Pass custom arguments to custom formatters via inline JSON or a JSON file path. |
28231
+
| [`--formatters`](../template-customization.md#formatters) | Specify code formatters to apply to generated output. |
28232
+
| [`--use-double-quotes`](../template-customization.md#use-double-quotes) | Use double quotes for string literals in generated code. |
28233
+
| [`--wrap-string-literal`](../template-customization.md#wrap-string-literal) | Wrap long string literals across multiple lines. |
| [Type Alias](#type-alias) | 2 | TypeAlias and root-model alias output. |
28252
+
| [Type Mapping](#type-mapping) | 9 | Scalar, date/time, and custom type mapping. |
28253
+
| [Type Syntax](#type-syntax) | 3 | Modern annotation syntax and Annotated usage. |
28254
+
28255
+
## Imports {#imports}
28256
+
28257
+
Generated imports and type-checking import behavior.
28258
+
28259
+
| Option | Description |
28260
+
|--------|-------------|
28261
+
| [`--disable-future-imports`](../typing-customization.md#disable-future-imports) | Prevent automatic addition of __future__ imports in generated code. |
28262
+
28263
+
## Collection Types {#collection-types}
28264
+
28265
+
Collection and tuple/set generation.
28266
+
28267
+
| Option | Description |
28268
+
|--------|-------------|
28269
+
| [`--no-use-standard-collections`](../typing-customization.md#no-use-standard-collections) | Use typing.Dict/List instead of built-in dict/list for container types. |
28270
+
| [`--use-generic-container-types`](../typing-customization.md#use-generic-container-types) | Use generic container types (Sequence, Mapping) for type hinting. |
28271
+
| [`--use-standard-collections`](../typing-customization.md#use-standard-collections) | Use built-in dict/list instead of typing.Dict/List. |
28272
+
| [`--use-tuple-for-fixed-items`](../typing-customization.md#use-tuple-for-fixed-items) | Generate tuple types for arrays with items array syntax. |
28273
+
| [`--use-unique-items-as-set`](../typing-customization.md#use-unique-items-as-set) | Generate set types for arrays with uniqueItems constraint. |
28274
+
28275
+
## Type Alias {#type-alias}
28276
+
28277
+
TypeAlias and root-model alias output.
28278
+
28279
+
| Option | Description |
28280
+
|--------|-------------|
28281
+
| [`--use-root-model-type-alias`](../typing-customization.md#use-root-model-type-alias) | Generate RootModel as type alias format for better mypy support. |
28282
+
| [`--use-type-alias`](../typing-customization.md#use-type-alias) | Use TypeAlias instead of root models for type definitions (experimental). |
28283
+
28284
+
## Type Mapping {#type-mapping}
28285
+
28286
+
Scalar, date/time, and custom type mapping.
28287
+
28288
+
| Option | Description |
28289
+
|--------|-------------|
28290
+
| [`--output-date-class`](../typing-customization.md#output-date-class) | Specify date class type for date schema fields. |
28291
+
| [`--output-datetime-class`](../typing-customization.md#output-datetime-class) | Specify datetime class type for date-time schema fields. |
28292
+
| [`--strict-types`](../typing-customization.md#strict-types) | Enable strict type validation for specified Python types. |
28293
+
| [`--type-mappings`](../typing-customization.md#type-mappings) | Override default type mappings for schema formats. |
28294
+
| [`--type-overrides`](../typing-customization.md#type-overrides) | Replace schema model types with custom Python types via JSON mapping. |
28295
+
| [`--use-decimal-for-multiple-of`](../typing-customization.md#use-decimal-for-multiple-of) | Generate Decimal types for fields with multipleOf constraint. |
28296
+
| [`--use-object-type`](../typing-customization.md#use-object-type) | Use object instead of Any for unspecified object and array values. |
28297
+
| [`--use-pendulum`](../typing-customization.md#use-pendulum) | Use pendulum types for date, time, and duration fields. |
28298
+
| [`--use-standard-primitive-types`](../typing-customization.md#use-standard-primitive-types) | Use Python standard library types for string formats instead of str. |
28299
+
28300
+
## Type Syntax {#type-syntax}
28301
+
28302
+
Modern annotation syntax and Annotated usage.
28303
+
28304
+
| Option | Description |
28305
+
|--------|-------------|
28306
+
| [`--no-use-union-operator`](../typing-customization.md#no-use-union-operator) | Use Union\[X, Y\] / Optional\[X\] instead of X \| Y union operator. |
28307
+
| [`--use-annotated`](../typing-customization.md#use-annotated) | Use typing.Annotated for Field() with constraints. |
28308
+
| [`--use-union-operator`](../typing-customization.md#use-union-operator) | Use \| operator for Union types (PEP 604). |
| [Read Only Write Only](#read-only-write-only) | 2 | readOnly/writeOnly model behavior. |
28328
+
28329
+
## OpenAPI Naming {#openapi-naming}
28330
+
28331
+
Operation and response model naming.
28332
+
28333
+
| Option | Description |
28334
+
|--------|-------------|
28335
+
| [`--use-operation-id-as-name`](../openapi-only-options.md#use-operation-id-as-name) | Use OpenAPI operationId as the generated function/class name. |
28336
+
| [`--use-status-code-in-response-name`](../openapi-only-options.md#use-status-code-in-response-name) | Include HTTP status code in response model names. |
28337
+
28338
+
## OpenAPI Paths {#openapi-paths}
28339
+
28340
+
Path selection and path parameter output.
28341
+
28342
+
| Option | Description |
28343
+
|--------|-------------|
28344
+
| [`--include-path-parameters`](../openapi-only-options.md#include-path-parameters) | Include OpenAPI path parameters in generated parameter models. |
28345
+
| [`--openapi-include-paths`](../openapi-only-options.md#openapi-include-paths) | Filter OpenAPI paths to include in model generation. |
| [`--read-only-write-only-model-type`](../openapi-only-options.md#read-only-write-only-model-type) | Generate separate request and response models for readOnly/writeOnly fields. |
28362
+
| [`--use-frozen-field`](../model-customization.md#use-frozen-field) | Generate frozen (immutable) field definitions for readOnly properties. |
- [Model Customization](https://datamodel-code-generator.koxudaxi.dev/cli-reference/topics/model-customization/): Choose model class shape, naming, reuse, and root-model behavior.
- [Typing Customization](https://datamodel-code-generator.koxudaxi.dev/cli-reference/topics/typing-customization/): Control Python annotation syntax, collection types, imports, and type mappings.
- [Quick Reference](https://datamodel-code-generator.koxudaxi.dev/cli-reference/quick-reference/): All CLI options in one page for easy **Ctrl+F** searching.
0 commit comments