datamodel-code-generator 0.29.0__py3-none-any.whl → 0.30.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of datamodel-code-generator might be problematic. Click here for more details.
- datamodel_code_generator/__init__.py +2 -0
- datamodel_code_generator/__main__.py +2 -0
- datamodel_code_generator/arguments.py +6 -0
- datamodel_code_generator/parser/base.py +2 -0
- datamodel_code_generator/parser/graphql.py +2 -0
- datamodel_code_generator/parser/jsonschema.py +2 -0
- datamodel_code_generator/parser/openapi.py +2 -0
- datamodel_code_generator/reference.py +16 -0
- {datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/METADATA +3 -1
- {datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/RECORD +13 -13
- {datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/WHEEL +0 -0
- {datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/entry_points.txt +0 -0
- {datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -287,6 +287,7 @@ def generate( # noqa: PLR0912, PLR0913, PLR0914, PLR0915
|
|
|
287
287
|
keyword_only: bool = False,
|
|
288
288
|
no_alias: bool = False,
|
|
289
289
|
formatters: list[Formatter] = DEFAULT_FORMATTERS,
|
|
290
|
+
parent_scoped_naming: bool = False,
|
|
290
291
|
) -> None:
|
|
291
292
|
remote_text_cache: DefaultPutDict[str, str] = DefaultPutDict()
|
|
292
293
|
if isinstance(input_, str):
|
|
@@ -483,6 +484,7 @@ def generate( # noqa: PLR0912, PLR0913, PLR0914, PLR0915
|
|
|
483
484
|
no_alias=no_alias,
|
|
484
485
|
formatters=formatters,
|
|
485
486
|
encoding=encoding,
|
|
487
|
+
parent_scoped_naming=parent_scoped_naming,
|
|
486
488
|
**kwargs,
|
|
487
489
|
)
|
|
488
490
|
|
|
@@ -314,6 +314,7 @@ class Config(BaseModel):
|
|
|
314
314
|
keyword_only: bool = False
|
|
315
315
|
no_alias: bool = False
|
|
316
316
|
formatters: list[Formatter] = DEFAULT_FORMATTERS
|
|
317
|
+
parent_scoped_naming: bool = False
|
|
317
318
|
|
|
318
319
|
def merge_args(self, args: Namespace) -> None:
|
|
319
320
|
set_args = {f: getattr(args, f) for f in self.get_fields() if getattr(args, f) is not None}
|
|
@@ -525,6 +526,7 @@ def main(args: Sequence[str] | None = None) -> Exit: # noqa: PLR0911, PLR0912,
|
|
|
525
526
|
keyword_only=config.keyword_only,
|
|
526
527
|
no_alias=config.no_alias,
|
|
527
528
|
formatters=config.formatters,
|
|
529
|
+
parent_scoped_naming=config.parent_scoped_naming,
|
|
528
530
|
)
|
|
529
531
|
except InvalidClassNameError as e:
|
|
530
532
|
print(f"{e} You have to set `--class-name` option", file=sys.stderr) # noqa: T201
|
|
@@ -202,6 +202,12 @@ model_options.add_argument(
|
|
|
202
202
|
choices=[i.value for i in DatetimeClassType],
|
|
203
203
|
default=None,
|
|
204
204
|
)
|
|
205
|
+
model_options.add_argument(
|
|
206
|
+
"--parent-scoped-naming",
|
|
207
|
+
help="Set name of models defined inline from the parent model",
|
|
208
|
+
action="store_true",
|
|
209
|
+
default=None,
|
|
210
|
+
)
|
|
205
211
|
|
|
206
212
|
# ======================================================================================
|
|
207
213
|
# Typing options for generated models
|
|
@@ -377,6 +377,7 @@ class Parser(ABC):
|
|
|
377
377
|
keyword_only: bool = False,
|
|
378
378
|
no_alias: bool = False,
|
|
379
379
|
formatters: list[Formatter] = DEFAULT_FORMATTERS,
|
|
380
|
+
parent_scoped_naming: bool = False,
|
|
380
381
|
) -> None:
|
|
381
382
|
self.keyword_only = keyword_only
|
|
382
383
|
self.data_type_manager: DataTypeManager = data_type_manager_type(
|
|
@@ -463,6 +464,7 @@ class Parser(ABC):
|
|
|
463
464
|
remove_special_field_name_prefix=remove_special_field_name_prefix,
|
|
464
465
|
capitalise_enum_members=capitalise_enum_members,
|
|
465
466
|
no_alias=no_alias,
|
|
467
|
+
parent_scoped_naming=parent_scoped_naming,
|
|
466
468
|
)
|
|
467
469
|
self.class_name: str | None = class_name
|
|
468
470
|
self.wrap_string_literal: bool | None = wrap_string_literal
|
|
@@ -154,6 +154,7 @@ class GraphQLParser(Parser):
|
|
|
154
154
|
keyword_only: bool = False,
|
|
155
155
|
no_alias: bool = False,
|
|
156
156
|
formatters: list[Formatter] = DEFAULT_FORMATTERS,
|
|
157
|
+
parent_scoped_naming: bool = False,
|
|
157
158
|
) -> None:
|
|
158
159
|
super().__init__(
|
|
159
160
|
source=source,
|
|
@@ -228,6 +229,7 @@ class GraphQLParser(Parser):
|
|
|
228
229
|
keyword_only=keyword_only,
|
|
229
230
|
no_alias=no_alias,
|
|
230
231
|
formatters=formatters,
|
|
232
|
+
parent_scoped_naming=parent_scoped_naming,
|
|
231
233
|
)
|
|
232
234
|
|
|
233
235
|
self.data_model_scalar_type = data_model_scalar_type
|
|
@@ -423,6 +423,7 @@ class JsonSchemaParser(Parser):
|
|
|
423
423
|
keyword_only: bool = False,
|
|
424
424
|
no_alias: bool = False,
|
|
425
425
|
formatters: list[Formatter] = DEFAULT_FORMATTERS,
|
|
426
|
+
parent_scoped_naming: bool = False,
|
|
426
427
|
) -> None:
|
|
427
428
|
super().__init__(
|
|
428
429
|
source=source,
|
|
@@ -497,6 +498,7 @@ class JsonSchemaParser(Parser):
|
|
|
497
498
|
keyword_only=keyword_only,
|
|
498
499
|
no_alias=no_alias,
|
|
499
500
|
formatters=formatters,
|
|
501
|
+
parent_scoped_naming=parent_scoped_naming,
|
|
500
502
|
)
|
|
501
503
|
|
|
502
504
|
self.remote_object_cache: DefaultPutDict[str, dict[str, Any]] = DefaultPutDict()
|
|
@@ -216,6 +216,7 @@ class OpenAPIParser(JsonSchemaParser):
|
|
|
216
216
|
keyword_only: bool = False,
|
|
217
217
|
no_alias: bool = False,
|
|
218
218
|
formatters: list[Formatter] = DEFAULT_FORMATTERS,
|
|
219
|
+
parent_scoped_naming: bool = False,
|
|
219
220
|
) -> None:
|
|
220
221
|
super().__init__(
|
|
221
222
|
source=source,
|
|
@@ -290,6 +291,7 @@ class OpenAPIParser(JsonSchemaParser):
|
|
|
290
291
|
keyword_only=keyword_only,
|
|
291
292
|
no_alias=no_alias,
|
|
292
293
|
formatters=formatters,
|
|
294
|
+
parent_scoped_naming=parent_scoped_naming,
|
|
293
295
|
)
|
|
294
296
|
self.open_api_scopes: list[OpenAPIScope] = openapi_scopes or [OpenAPIScope.Schemas]
|
|
295
297
|
|
|
@@ -318,6 +318,7 @@ class ModelResolver: # noqa: PLR0904
|
|
|
318
318
|
capitalise_enum_members: bool = False, # noqa: FBT001, FBT002
|
|
319
319
|
no_alias: bool = False, # noqa: FBT001, FBT002
|
|
320
320
|
remove_suffix_number: bool = False, # noqa: FBT001, FBT002
|
|
321
|
+
parent_scoped_naming: bool = False, # noqa: FBT001, FBT002
|
|
321
322
|
) -> None:
|
|
322
323
|
self.references: dict[str, Reference] = {}
|
|
323
324
|
self._current_root: Sequence[str] = []
|
|
@@ -351,6 +352,7 @@ class ModelResolver: # noqa: PLR0904
|
|
|
351
352
|
self._base_path: Path = base_path or Path.cwd()
|
|
352
353
|
self._current_base_path: Path | None = self._base_path
|
|
353
354
|
self.remove_suffix_number: bool = remove_suffix_number
|
|
355
|
+
self.parent_scoped_naming = parent_scoped_naming
|
|
354
356
|
|
|
355
357
|
@property
|
|
356
358
|
def current_base_path(self) -> Path | None:
|
|
@@ -512,6 +514,19 @@ class ModelResolver: # noqa: PLR0904
|
|
|
512
514
|
self.references[path] = reference
|
|
513
515
|
return reference
|
|
514
516
|
|
|
517
|
+
def _check_parent_scope_option(self, name: str, path: Sequence[str]) -> str:
|
|
518
|
+
if self.parent_scoped_naming:
|
|
519
|
+
parent_reference = None
|
|
520
|
+
parent_path = path[:-1]
|
|
521
|
+
while parent_path:
|
|
522
|
+
parent_reference = self.references.get(self.join_path(parent_path))
|
|
523
|
+
if parent_reference is not None:
|
|
524
|
+
break
|
|
525
|
+
parent_path = parent_path[:-1]
|
|
526
|
+
if parent_reference:
|
|
527
|
+
name = f"{parent_reference.name}_{name}"
|
|
528
|
+
return name
|
|
529
|
+
|
|
515
530
|
def add( # noqa: PLR0913
|
|
516
531
|
self,
|
|
517
532
|
path: Sequence[str],
|
|
@@ -533,6 +548,7 @@ class ModelResolver: # noqa: PLR0904
|
|
|
533
548
|
name = original_name
|
|
534
549
|
duplicate_name: str | None = None
|
|
535
550
|
if class_name:
|
|
551
|
+
name = self._check_parent_scope_option(name, path)
|
|
536
552
|
name, duplicate_name = self.get_class_name(
|
|
537
553
|
name=name,
|
|
538
554
|
unique=unique,
|
{datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datamodel-code-generator
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.30.0
|
|
4
4
|
Summary: Datamodel Code Generator
|
|
5
5
|
Project-URL: Homepage, https://github.com/koxudaxi/datamodel-code-generator
|
|
6
6
|
Project-URL: Source, https://github.com/koxudaxi/datamodel-code-generator
|
|
@@ -512,6 +512,8 @@ Model customization:
|
|
|
512
512
|
Choose Datetime class between AwareDatetime, NaiveDatetime or
|
|
513
513
|
datetime. Each output model has its default mapping (for example
|
|
514
514
|
pydantic: datetime, dataclass: str, ...)
|
|
515
|
+
--parent-scoped-naming
|
|
516
|
+
Set name of models defined inline from the parent model
|
|
515
517
|
--reuse-model Reuse models on the field when a module has the model with the same
|
|
516
518
|
content
|
|
517
519
|
--target-python-version {3.9,3.10,3.11,3.12,3.13}
|
{datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/RECORD
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
datamodel_code_generator/__init__.py,sha256=
|
|
2
|
-
datamodel_code_generator/__main__.py,sha256=
|
|
3
|
-
datamodel_code_generator/arguments.py,sha256=
|
|
1
|
+
datamodel_code_generator/__init__.py,sha256=2h8FA8O_x1VGRVlXKJHt3jwuC34MIEnmHwHv-zGuF_I,20445
|
|
2
|
+
datamodel_code_generator/__main__.py,sha256=rF1Se8R0rfqDmJ4_INBdOYlU7G4XIthPCe3ldDwtgQI,22608
|
|
3
|
+
datamodel_code_generator/arguments.py,sha256=xPAnid2-dC_Hj4o1hY9fL13NMJl5wCPphTsCHZ3QeNQ,16637
|
|
4
4
|
datamodel_code_generator/format.py,sha256=zvX0KH1uWwGnTYoVM4KhAuKZn5erjkH5eyi4t3leirw,8962
|
|
5
5
|
datamodel_code_generator/http.py,sha256=LE94GC7I9D8lWIg_YAGWedfy0XNxOXTmiYKuNMTwouo,887
|
|
6
6
|
datamodel_code_generator/imports.py,sha256=Nq83WbEGCegntg3WX4VbKfzAIs84alZ7IrYyNPrlUbc,5517
|
|
7
7
|
datamodel_code_generator/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
datamodel_code_generator/pydantic_patch.py,sha256=co1IUDvZqQ-xEZ3C9gbV-BVm2Cin1vfyZNr2Dr0LdHY,718
|
|
9
|
-
datamodel_code_generator/reference.py,sha256=
|
|
9
|
+
datamodel_code_generator/reference.py,sha256=OobfjN5hWaKzv4ECdCPc9Q3ODkoG93B4qaKlzDEcDrY,26748
|
|
10
10
|
datamodel_code_generator/types.py,sha256=fobUZnNTOGpzF4qZMraoLogVkAU7zBdFVG-8SOFoDD4,21163
|
|
11
11
|
datamodel_code_generator/util.py,sha256=mZW8-6CbFe6T4IY5OM9Av6cH-0VknQGe2eIKjTM6Jzo,2729
|
|
12
12
|
datamodel_code_generator/model/__init__.py,sha256=pJlJ1juQ-Gv17ZKXy6OAfJSSoOAmYQ7QCbdneu1BENU,3594
|
|
@@ -48,12 +48,12 @@ datamodel_code_generator/model/template/pydantic_v2/BaseModel.jinja2,sha256=i1Wg
|
|
|
48
48
|
datamodel_code_generator/model/template/pydantic_v2/ConfigDict.jinja2,sha256=xHvBYrh__32O1xRCSl6_u5zbyYIjB8a5k8fZiTo0spY,149
|
|
49
49
|
datamodel_code_generator/model/template/pydantic_v2/RootModel.jinja2,sha256=XQBlML7Hm5hN6_AExENNvVc_yxNWijcIfTTbbmegCpE,1223
|
|
50
50
|
datamodel_code_generator/parser/__init__.py,sha256=3XtFcDPocaetfjmWFqj_CubqNCDipb7vXZHsYKdJXXU,851
|
|
51
|
-
datamodel_code_generator/parser/base.py,sha256=
|
|
52
|
-
datamodel_code_generator/parser/graphql.py,sha256=
|
|
53
|
-
datamodel_code_generator/parser/jsonschema.py,sha256=
|
|
54
|
-
datamodel_code_generator/parser/openapi.py,sha256=
|
|
55
|
-
datamodel_code_generator-0.
|
|
56
|
-
datamodel_code_generator-0.
|
|
57
|
-
datamodel_code_generator-0.
|
|
58
|
-
datamodel_code_generator-0.
|
|
59
|
-
datamodel_code_generator-0.
|
|
51
|
+
datamodel_code_generator/parser/base.py,sha256=iI57e61U2YgG9K8vuBjw72dM034bgsBrfOFL1zG7Y-w,61839
|
|
52
|
+
datamodel_code_generator/parser/graphql.py,sha256=scotG-q8zTS40i5rP9HfhriSVhXVnxEKtuBoXvbzECg,22684
|
|
53
|
+
datamodel_code_generator/parser/jsonschema.py,sha256=bwXNvXjG8tiUPCNZsEXbo2TlCYJVKIzeYWEKfvlPzo8,70011
|
|
54
|
+
datamodel_code_generator/parser/openapi.py,sha256=3IWF40DK0a710rVqXCod7Hi3Fh9u7neD4YR_kn_6VD4,27279
|
|
55
|
+
datamodel_code_generator-0.30.0.dist-info/METADATA,sha256=u9lGxU2--PWj6uTxDi6AA-Dvyw06mhn2KQy_j4ewbds,25294
|
|
56
|
+
datamodel_code_generator-0.30.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
57
|
+
datamodel_code_generator-0.30.0.dist-info/entry_points.txt,sha256=cJVcHiEViQMANaoM5C1xR5hzmyCqH6hHHMpV8W00in8,77
|
|
58
|
+
datamodel_code_generator-0.30.0.dist-info/licenses/LICENSE,sha256=K54Lwc6_jduycsy8oFFjQEeSSuEiqvVIjCGIXOMnuTQ,1068
|
|
59
|
+
datamodel_code_generator-0.30.0.dist-info/RECORD,,
|
{datamodel_code_generator-0.29.0.dist-info → datamodel_code_generator-0.30.0.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|