-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathmodels.py
More file actions
63 lines (45 loc) · 2.97 KB
/
models.py
File metadata and controls
63 lines (45 loc) · 2.97 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Pydantic models based on OpenAPI schema definitions.
"""
from datetime import datetime
from typing import List, Optional
from uuid import UUID
from pydantic import BaseModel, Field
# Request/Response Models
class NewPostRequest(BaseModel):
username: str = Field(..., min_length=1, max_length=50, description="Username of the post author")
content: str = Field(..., min_length=1, max_length=2000, description="Content of the post")
class UpdatePostRequest(BaseModel):
username: str = Field(..., min_length=1, max_length=50, description="Username of the post author (for validation)")
content: str = Field(..., min_length=1, max_length=2000, description="Updated content of the post")
class NewCommentRequest(BaseModel):
username: str = Field(..., min_length=1, max_length=50, description="Username of the comment author")
content: str = Field(..., min_length=1, max_length=1000, description="Content of the comment")
class UpdateCommentRequest(BaseModel):
username: str = Field(..., min_length=1, max_length=50, description="Username of the comment author (for validation)")
content: str = Field(..., min_length=1, max_length=1000, description="Updated content of the comment")
class LikeRequest(BaseModel):
username: str = Field(..., description="Username of the user liking the post")
class LikeResponse(BaseModel):
postId: str = Field(..., description="ID of the liked post")
username: str = Field(..., description="Username of the user who liked the post")
likedAt: datetime = Field(..., description="Timestamp when the post was liked")
class Post(BaseModel):
id: str = Field(..., description="Unique identifier for the post")
username: str = Field(..., min_length=1, max_length=50, description="Username of the post author")
content: str = Field(..., min_length=1, max_length=2000, description="Content of the post")
createdAt: datetime = Field(..., description="Timestamp when the post was created")
updatedAt: datetime = Field(..., description="Timestamp when the post was last updated")
likesCount: int = Field(..., ge=0, description="Number of likes on the post")
commentsCount: int = Field(..., ge=0, description="Number of comments on the post")
class Comment(BaseModel):
id: str = Field(..., description="Unique identifier for the comment")
postId: str = Field(..., description="ID of the post this comment belongs to")
username: str = Field(..., min_length=1, max_length=50, description="Username of the comment author")
content: str = Field(..., min_length=1, max_length=1000, description="Content of the comment")
createdAt: str = Field(..., description="Timestamp when the comment was created")
updatedAt: str = Field(..., description="Timestamp when the comment was last updated")
class Error(BaseModel):
error: str = Field(..., description="Error type")
message: str = Field(..., description="Error message")
details: Optional[List[str]] = Field(None, description="Additional error details")