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
Add documentation for reducing duplicate field types (#2896)
* Add documentation for reducing duplicate field types with --use-type-alias
* docs: update CLI reference documentation and prompt data
🤖 Generated by GitHub Actions
* Use heading instead of bold for Result section
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@@ -12,6 +12,7 @@ When generating models from schemas, you may encounter duplicate model definitio
12
12
|`--reuse-scope`| Control scope of deduplication (`root` or `tree`) |
13
13
|`--shared-module-name`| Name for shared module in multi-file output |
14
14
|`--collapse-root-models`| Inline root models instead of creating wrappers |
15
+
|`--use-type-alias`| Create TypeAlias for reusable field types (see [Reducing Duplicate Field Types](#reducing-duplicate-field-types)) |
15
16
16
17
---
17
18
@@ -243,10 +244,98 @@ models/
243
244
244
245
---
245
246
247
+
## Reducing Duplicate Field Types
248
+
249
+
When multiple classes share the same field type with identical constraints or metadata, you can reduce duplication by defining the type once in `$defs` and referencing it with `$ref`. Combined with `--use-type-alias`, this creates a single TypeAlias that's reused across all classes.
250
+
251
+
### Problem: Duplicate Annotated Fields
252
+
253
+
Without using `$ref`, each class gets its own inline field definition:
0 commit comments