From 7ce5e5d0d42005c1ad0d32ffb8c1c18a3810ff86 Mon Sep 17 00:00:00 2001 From: Georg K Date: Fri, 14 Jul 2023 05:21:43 +0300 Subject: [PATCH] feat: update root model defs --- .gitlab-ci.yml | 2 +- aiohttp_pydantic/injectors.py | 2 +- tests/test_oas/test_view.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ebd333..4daa603 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: publish-pypi: stage: package - image: python:3.10 + image: python:3.11 script: - sed -i -e "s/1.12.1/${CI_COMMIT_TAG:1}/g" aiohttp_pydantic/__init__.py - pip install -U setuptools wheel pip; pip install invoke diff --git a/aiohttp_pydantic/injectors.py b/aiohttp_pydantic/injectors.py index d8d29bc..80df04f 100644 --- a/aiohttp_pydantic/injectors.py +++ b/aiohttp_pydantic/injectors.py @@ -68,7 +68,7 @@ class BodyGetter(AbstractInjector): def __init__(self, args_spec: dict, default_values: dict): self.arg_name, self.model = next(iter(args_spec.items())) - schema = self.model.schema() + schema = self.model.model_json_schema() if "type" not in schema: schema["type"] = "object" self._expect_object = schema["type"] == "object" diff --git a/tests/test_oas/test_view.py b/tests/test_oas/test_view.py index 679c236..d407e11 100644 --- a/tests/test_oas/test_view.py +++ b/tests/test_oas/test_view.py @@ -55,7 +55,8 @@ class Dog(BaseModel): barks: float -Animal = RootModel[Annotated[Union[Cat, Dog], Field(discriminator='pet_type')]] +class Animal(RootModel): + root: Annotated[Union[Cat, Dog], Field(discriminator='pet_type')] class PetCollectionView(PydanticView):