feat: update root model defs
This commit is contained in:
parent
93e391b7b2
commit
7ce5e5d0d4
@ -3,7 +3,7 @@ stages:
|
|||||||
|
|
||||||
publish-pypi:
|
publish-pypi:
|
||||||
stage: package
|
stage: package
|
||||||
image: python:3.10
|
image: python:3.11
|
||||||
script:
|
script:
|
||||||
- sed -i -e "s/1.12.1/${CI_COMMIT_TAG:1}/g" aiohttp_pydantic/__init__.py
|
- 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
|
- pip install -U setuptools wheel pip; pip install invoke
|
||||||
|
@ -68,7 +68,7 @@ class BodyGetter(AbstractInjector):
|
|||||||
|
|
||||||
def __init__(self, args_spec: dict, default_values: dict):
|
def __init__(self, args_spec: dict, default_values: dict):
|
||||||
self.arg_name, self.model = next(iter(args_spec.items()))
|
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:
|
if "type" not in schema:
|
||||||
schema["type"] = "object"
|
schema["type"] = "object"
|
||||||
self._expect_object = schema["type"] == "object"
|
self._expect_object = schema["type"] == "object"
|
||||||
|
@ -55,7 +55,8 @@ class Dog(BaseModel):
|
|||||||
barks: float
|
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):
|
class PetCollectionView(PydanticView):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user