inherit choices validators and class validators for fields in generated pydantic models

This commit is contained in:
collerek
2021-10-11 16:22:50 +02:00
parent f6458be157
commit 9559c0f7f6
6 changed files with 46 additions and 25 deletions

View File

@ -4,11 +4,8 @@ from fastapi import FastAPI
from starlette.testclient import TestClient
from tests.settings import DATABASE_URL
from tests.test_inheritance_and_pydantic_generation.test_geting_the_pydantic_models import (
from tests.test_inheritance_and_pydantic_generation.test_geting_pydantic_models import (
Category,
Item,
MutualA,
MutualB,
SelfRef,
database,
metadata,
@ -53,7 +50,9 @@ app.post("/categories/", response_model=Category)(create_category)
response_model=SelfRef.get_pydantic(exclude={"parent", "children__name"}),
)
async def create_selfref(
selfref: SelfRef.get_pydantic(exclude={"children__name"}), # type: ignore
selfref: SelfRef.get_pydantic( # type: ignore
exclude={"children__name"} # noqa: F821
),
):
selfr = SelfRef(**selfref.dict())
await selfr.save()