-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathchild.py
39 lines (25 loc) · 868 Bytes
/
child.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from typing import TYPE_CHECKING, List
from pydantic import ConfigDict
from fastapi_jsonapi.schema_base import BaseModel, Field, RelationshipInfo
if TYPE_CHECKING:
from .parent_child_association import ParentToChildAssociationSchema
class ChildBaseSchema(BaseModel):
"""Child base schema."""
model_config = ConfigDict(from_attributes=True)
name: str
parents: List["ParentToChildAssociationSchema"] = Field(
default=None,
json_schema_extra={
"relationship": RelationshipInfo(
resource_type="parent_child_association",
many=True,
),
},
)
class ChildPatchSchema(ChildBaseSchema):
"""Child PATCH schema."""
class ChildInSchema(ChildBaseSchema):
"""Child input schema."""
class ChildSchema(ChildInSchema):
"""Child item schema."""
id: int