Skip to content

Commit dd01614

Browse files
committed
fix: Correct expected literal schema for Pydantic 2.7.
1 parent 896435b commit dd01614

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/util/test_pydantic_field.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Union
1+
from typing import Union
22

33
from pydantic import BaseModel, Field
44
from typing_extensions import Literal
@@ -59,17 +59,16 @@ def construct_base_open_api() -> OpenAPI:
5959
def test_pydantic_discriminator_schema_generation() -> None:
6060
"""https://github.com/kuimono/openapi-schema-pydantic/issues/8"""
6161

62-
a_kind: Dict[str, Any]
63-
b_kind: Dict[str, Any]
62+
a_kind = {"const": "a", "enum": ["a"], "title": "Kind", "type": "string"}
63+
b_kind = {"const": "b", "enum": ["b"], "title": "Kind", "type": "string"}
6464

6565
if PYDANTIC_V2:
6666
_key_map, json_schema = models_json_schema([(RequestModel, "validation")])
67-
a_kind = {"const": "a", "title": "Kind"}
68-
b_kind = {"const": "b", "title": "Kind"}
6967
else:
7068
json_schema = v1_schema([RequestModel])
71-
a_kind = {"enum": ["a"], "title": "Kind", "type": "string"}
72-
b_kind = {"enum": ["b"], "title": "Kind", "type": "string"}
69+
a_kind.pop("const")
70+
b_kind.pop("const")
71+
7372
assert json_schema == {
7473
DEFS_KEY: {
7574
"DataAModel": {

0 commit comments

Comments
 (0)