Skip to content

Commit b22c8d2

Browse files
committed
test: add test case for json schema
1 parent 272181e commit b22c8d2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_pydantic/test_generic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,11 @@ def test_invalid_generics(data_type, data_value, error_loc, error_type):
7272
[error_dict] = raised.value.errors()
7373
assert error_dict["loc"] == error_loc
7474
assert error_dict["type"] == error_type
75+
76+
77+
def test_generic_json_schema():
78+
schema = Response[DataModel].model_json_schema()
79+
# Should have referenced the schema in $defs
80+
assert schema["properties"]["data"]["anyOf"][0] == {"$ref": "#/$defs/DataModel"}
81+
# Schema in $defs should match DataModel's schema.
82+
assert schema["$defs"]["DataModel"] == DataModel.model_json_schema()

0 commit comments

Comments
 (0)