Skip to content

Commit 2f6940b

Browse files
committed
Don't convert standalone enums in V1
1 parent 70fd0a2 commit 2f6940b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

pydantic2ts/cli/script.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,8 @@ def generate_json_schema_v1(
254254
for e in enums:
255255
add_enum_names_v1(e)
256256

257-
all_models = models + enums
258257
master_model = create_model(
259-
"_Master_", **{m.__name__: (m, ...) for m in all_models}
258+
"_Master_", **{m.__name__: (m, ...) for m in models}
260259
)
261260
master_model.Config.extra = "forbid"
262261
master_model.Config.schema_extra = staticmethod(clean_schema)

tests/expected_results/enums/v1/input.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from enum import Enum
12
from typing import List, Optional
23

34
from pydantic import BaseModel
@@ -23,3 +24,8 @@ class AnimalShelter(BaseModel):
2324
dogs: List[Dog]
2425
owner: Optional[Dog]
2526
master: Cat
27+
28+
29+
class Standalone(Enum):
30+
something = "something"
31+
anything = "anything"

tests/expected_results/enums/v2/input.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from enum import Enum
12
from typing import List, Optional
23

34
from pydantic import BaseModel
@@ -23,3 +24,8 @@ class AnimalShelter(BaseModel):
2324
dogs: List[Dog]
2425
owner: Optional[Dog]
2526
master: Cat
27+
28+
29+
class Standalone(Enum):
30+
something = "something"
31+
anything = "anything"

0 commit comments

Comments
 (0)