From dd0161473fb19c87e248c54613643867987cf71a Mon Sep 17 00:00:00 2001 From: Mike Oakley <18501112+mike-oakley@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:13:15 +0000 Subject: [PATCH] fix: Correct expected literal schema for Pydantic 2.7. --- tests/util/test_pydantic_field.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/util/test_pydantic_field.py b/tests/util/test_pydantic_field.py index fd5bbf3..64cdee0 100644 --- a/tests/util/test_pydantic_field.py +++ b/tests/util/test_pydantic_field.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Union +from typing import Union from pydantic import BaseModel, Field from typing_extensions import Literal @@ -59,17 +59,16 @@ def construct_base_open_api() -> OpenAPI: def test_pydantic_discriminator_schema_generation() -> None: """https://github.com/kuimono/openapi-schema-pydantic/issues/8""" - a_kind: Dict[str, Any] - b_kind: Dict[str, Any] + a_kind = {"const": "a", "enum": ["a"], "title": "Kind", "type": "string"} + b_kind = {"const": "b", "enum": ["b"], "title": "Kind", "type": "string"} if PYDANTIC_V2: _key_map, json_schema = models_json_schema([(RequestModel, "validation")]) - a_kind = {"const": "a", "title": "Kind"} - b_kind = {"const": "b", "title": "Kind"} else: json_schema = v1_schema([RequestModel]) - a_kind = {"enum": ["a"], "title": "Kind", "type": "string"} - b_kind = {"enum": ["b"], "title": "Kind", "type": "string"} + a_kind.pop("const") + b_kind.pop("const") + assert json_schema == { DEFS_KEY: { "DataAModel": {