-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpost_comment.py
48 lines (32 loc) · 1.11 KB
/
post_comment.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
40
41
42
43
44
45
46
47
48
"""Post Comment schemas module."""
from datetime import datetime
from typing import TYPE_CHECKING
from pydantic import ConfigDict
from fastapi_jsonapi.schema_base import BaseModel, Field, RelationshipInfo
if TYPE_CHECKING:
from .post import PostSchema
from .user import UserSchema
class PostCommentBaseSchema(BaseModel):
"""PostComment base schema."""
model_config = ConfigDict(from_attributes=True)
text: str
created_at: datetime = Field(description="Create datetime")
modified_at: datetime = Field(description="Update datetime")
post: "PostSchema" = Field(
relationship=RelationshipInfo(
resource_type="post",
),
)
author: "UserSchema" = Field(
relationship=RelationshipInfo(
resource_type="user",
),
)
class PostCommentPatchSchema(PostCommentBaseSchema):
"""PostComment PATCH schema."""
class PostCommentInSchema(PostCommentBaseSchema):
"""PostComment input schema."""
class PostCommentSchema(PostCommentInSchema):
"""PostComment item schema."""
model_config = ConfigDict(from_attributes=True)
id: int