Skip to content

Commit 85fa705

Browse files
committed
Fix incorrect default value in test schema for FamilyPets
1 parent 3146f44 commit 85fa705

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

tests/data/expected/main/jsonschema/has_default_value_pydantic_v2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TeamType(Enum):
1717

1818

1919
class ID(RootModel[str]):
20-
root: str
20+
root: str = 'abc'
2121

2222

2323
class Pet(BaseModel):
@@ -32,7 +32,9 @@ class Family(RootModel[list[ID]]):
3232

3333
class FamilyPets(RootModel[list[Pet]]):
3434
root: list[Pet] = Field(
35-
default_factory=lambda: [Pet.model_validate(v) for v in ['taro', 'shiro']]
35+
default_factory=lambda: [
36+
Pet.model_validate(v) for v in [{'name': 'taro'}, {'name': 'shiro'}]
37+
]
3638
)
3739

3840

tests/data/jsonschema/has_default_value.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"$ref": "#/definitions/Pet"
4646
},
4747
"default": [
48-
"taro",
49-
"shiro"
48+
{"name": "taro"},
49+
{"name": "shiro"}
5050
]
5151
}
5252
},

tests/main/jsonschema/test_main_jsonschema.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3258,7 +3258,11 @@ def test_jsonschema_use_title_as_name_nested_titles_pydantic(output_file: Path)
32583258
("output_model", "expected_file"),
32593259
[
32603260
("pydantic.BaseModel", "has_default_value.py"),
3261-
("pydantic_v2.BaseModel", "has_default_value_pydantic_v2.py"),
3261+
pytest.param(
3262+
"pydantic_v2.BaseModel",
3263+
"has_default_value_pydantic_v2.py",
3264+
marks=PYDANTIC_V2_SKIP,
3265+
),
32623266
],
32633267
)
32643268
def test_main_jsonschema_has_default_value(output_model: str, expected_file: str, output_file: Path) -> None:

0 commit comments

Comments
 (0)