koxudaxi
datamodel-code-generator
BlogDocsChangelog

Add --use-type-alias flag to generate TypeAlias instead of root models

#2505
Comparing
butvinm:use-type-alias
(
8118a3b
) with
main
(
9d83669
)
CodSpeed Performance Gauge
0%
Untouched
32

Benchmarks

Passed

test_main_strict_types_all_with_field_constraints
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
65.2 ms65.1 ms
test_main_openapi_nullable_31
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
45.6 ms45.5 ms
test_main_jsonschema_nested_deep
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
66.2 ms66.1 ms
test_main_openapi_nullable
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
113.6 ms113.7 ms
test_main_collapse_root_models
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
71.2 ms71.2 ms
test_main_yaml
tests/main/test_main_yaml.py
CodSpeed Performance Gauge
0%
45.8 ms45.8 ms
test_main
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
103 ms103.1 ms
test_main_root_id_jsonschema_self_refs_with_remote_file
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
75.7 ms75.8 ms
test_main_strict_types
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
68.5 ms68.5 ms
test_main_root_id_jsonschema_self_refs_with_local_file
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
75.3 ms75.4 ms
test_main_jsonschema_special_field_name
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
58.1 ms58.2 ms
test_main_with_snake_case_field
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
105.9 ms106 ms
test_main_json_reuse_enum_default_member
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
68.5 ms68.5 ms
test_main_openapi_all_of_required
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
49.4 ms49.4 ms
test_main_jsonschema_collapsed_external_references
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
71.3 ms71.4 ms
test_main_jsonschema_complex_any_of
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
57.2 ms57.2 ms
test_main_all_of_ref
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
48.6 ms48.6 ms
test_main_jsonschema_required_and_any_of_required
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
55.7 ms55.8 ms
test_main_nested_directory
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
181.5 ms181.7 ms
test_main_jsonschema_id
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
49.8 ms49.9 ms
test_main_with_strip_default_none
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
101.7 ms101.9 ms
test_main_jsonschema_field_include_all_keys
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
55.2 ms55.3 ms
test_force_optional
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
110.1 ms110.3 ms
test_use_default
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
103.9 ms104.1 ms
test_main_jsonschema_no_empty_collapsed_external_model
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
45.1 ms45.2 ms
test_main_modular
tests/main/openapi/test_main_openapi.py
CodSpeed Performance Gauge
0%
230.4 ms230.9 ms
test_main_inheritance_forward_ref_keep_model_order
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
93.2 ms93.4 ms
test_main_external_definitions
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
47.3 ms47.4 ms
test_main_jsonschema_multiple_files
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
73.9 ms74.1 ms
test_main_inheritance_forward_ref
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
94.9 ms95.2 ms
test_main_autodetect
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
57.5 ms57.7 ms
test_main_jsonschema_external_files
tests/main/jsonschema/test_main_jsonschema.py
CodSpeed Performance Gauge
0%
47.3 ms47.4 ms

Commits

Click on a commit to change the comparison range
Base
main
9d83669
+0.02%
[pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci
ffe20ed
19 days ago
by pre-commit-ci[bot]
-0.09%
Update docs for --use-type-alias flag
ebf7f9a
19 days ago
by butvinm
-0.21%
Update README with --use-type-alias flag help
0edae77
19 days ago
by butvinm
-0.02%
Remove CLAUDE.md from repository
2ff188a
19 days ago
by butvinm
+0.48%
Fix cli argument after merge
9c7633e
19 days ago
by butvinm
-0.42%
Merge branch 'main' into use-type-alias
3e3df7d
19 days ago
by butvinm
-0.64%
refactor: Replace RootModel with TypeAlias for msgspec, TypedDict and dataclass This change replaces RootModel with TypeAlias for non-Pydantic output formats (msgspec, TypedDict, dataclass). Pydantic models continue to use RootModel when --use-type-alias is not specified. Changes: - Remove generic RootModel class and template (only used by non-Pydantic formats) - Update msgspec, dataclass, and TypedDict to always use TypeAlias for root models - Update test expectations for these output formats to use TypeAlias - Simplify model selection logic in get_data_model_types() for these formats Note: Pydantic v1/v2 models retain their existing behavior and can still generate RootModel when appropriate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
0e07ba4
18 days ago
by butvinm
-0.49%
Rename templates
323e347
18 days ago
by butvinm
+1.31%
Revert changes of GraphQL tests where we force python 3.10 back to default python 3.9
a4f479c
18 days ago
by butvinm
+0.02%
[pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci
3c71f43
12 days ago
by pre-commit-ci[bot]
+0.04%
Fix expected file melformed during refactoring
8da8568
12 days ago
by butvinm
-0.02%
Merge branch 'main' into use-type-alias
1fe7656
11 days ago
by koxudaxi
+0.05%
Remove expected test file github_api.py as never it is not used in tests
df2aeaa
11 days ago
by butvinm
-0.06%
Merge branch 'main' into use-type-alias
cf41882
10 days ago
by butvinm
-0.1%
Merge branch 'koxudaxi:main' into use-type-alias
582ed0a
8 days ago
by butvinm
+0.04%
Add documentation for root models and type aliases Add new documentation page explaining the difference between RootModel and type aliases, and when to use the --use-type-alias flag. The page includes: - Introduction explaining use cases for type aliases - Three examples showing RootModel, TypeAliasType, and type statement - All examples use Pydantic v2 syntax - Notes about limitations and usage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4e3088f
5 days ago
by butvinm
-0.04%
Move Notes section at the top
c6b8486
5 days ago
by butvinm
+0.01%
Update docs/root-model-and-type-alias.md Co-authored-by: Antonio Spadaro <ilovelinux@users.noreply.github.com>
8118a3b
3 days ago
by butvinm
© 2025 CodSpeed Technology
Home Terms Privacy Docs