Skip to content

Commit a78230a

Browse files
committed
Rewrite tests to ensure that the typescript output is identical for both v1 and v2 of pydantic; if a project upgrades to pydantic v2, the typescript definitions should not change unnecessarily
1 parent 1b82de0 commit a78230a

File tree

30 files changed

+50
-143
lines changed

30 files changed

+50
-143
lines changed

tests/expected_results/excluding_models/v2/output.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/expected_results/excluding_models/v2/input.py renamed to tests/expected_results/excluding_models/v2_input.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from typing import List, Optional
2+
13
from pydantic import BaseModel
2-
from typing import Optional, List
34

45

56
class LoginCredentials(BaseModel):

tests/expected_results/extra_fields/v1/input.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/expected_results/extra_fields/v1/output.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
try:
2+
from pydantic.v1 import BaseConfig, BaseModel, Extra
3+
except ImportError:
4+
from pydantic import BaseConfig, BaseModel, Extra
5+
6+
7+
class ModelExtraAllow(BaseModel):
8+
a: str
9+
10+
class Config(BaseConfig):
11+
extra = Extra.allow
12+
13+
14+
class ModelExtraForbid(BaseModel):
15+
a: str
16+
17+
class Config(BaseConfig):
18+
extra = Extra.forbid
19+
20+
21+
class ModelExtraIgnore(BaseModel):
22+
a: str
23+
24+
class Config(BaseConfig):
25+
extra = Extra.ignore
26+
27+
28+
class ModelExtraNone(BaseModel):
29+
a: str

0 commit comments

Comments
 (0)