-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathage_rating.py
More file actions
49 lines (35 loc) · 1.04 KB
/
age_rating.py
File metadata and controls
49 lines (35 loc) · 1.04 KB
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
40
41
42
43
44
45
46
47
48
49
from typing import TYPE_CHECKING, Annotated, Optional
from annotated_types import MaxLen, MinLen
from pydantic import ConfigDict
from fastapi_jsonapi.schema_base import BaseModel
from fastapi_jsonapi.types_metadata import RelationshipInfo
name_constrained = Annotated[
str,
MinLen(1),
MaxLen(20),
]
if TYPE_CHECKING:
from examples.api_for_sqlalchemy.schemas.movie import MovieSchema
class AgeRatingAttributesSchema(BaseModel):
model_config = ConfigDict(
from_attributes=True,
)
name: str
description: str
class AgeRatingBaseSchema(AgeRatingAttributesSchema):
movies: Annotated[
Optional[list["MovieSchema"]],
RelationshipInfo(
resource_type="movie",
many=True,
),
] = None
class AgeRatingCreateSchema(AgeRatingBaseSchema):
name: name_constrained
class AgeRatingUpdateSchema(AgeRatingBaseSchema):
name: Optional[name_constrained] = None
description: Optional[str] = None
class AgeRatingSchema(AgeRatingBaseSchema):
"""
Age Rating
"""