forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
87 lines (64 loc) · 1.72 KB
/
Copy pathmodels.py
File metadata and controls
87 lines (64 loc) · 1.72 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
Pydantic models for the FastAPI Social Media API
These models match the OpenAPI specification exactly.
"""
from typing import Optional
from pydantic import BaseModel
class Post(BaseModel):
"""Post model matching the OpenAPI specification"""
id: int
username: str
content: str
created_at: str
updated_at: str
like_count: int
comment_count: int
class Config:
from_attributes = True
class Comment(BaseModel):
"""Comment model matching the OpenAPI specification"""
id: int
post_id: int
username: str
content: str
created_at: str
updated_at: str
class Config:
from_attributes = True
class Like(BaseModel):
"""Like model matching the OpenAPI specification"""
id: int
post_id: int
username: str
created_at: str
class Config:
from_attributes = True
# Request models
class CreatePostRequest(BaseModel):
"""Request model for creating a new post"""
username: str
content: str
class UpdatePostRequest(BaseModel):
"""Request model for updating an existing post"""
username: str
content: str
class CreateCommentRequest(BaseModel):
"""Request model for creating a new comment"""
username: str
content: str
class UpdateCommentRequest(BaseModel):
"""Request model for updating an existing comment"""
username: str
content: str
class LikeRequest(BaseModel):
"""Request model for liking a post"""
username: str
class UnlikeRequest(BaseModel):
"""Request model for unliking a post"""
username: str
# Error response model
class Error(BaseModel):
"""Error response model matching the OpenAPI specification"""
error: str
message: str
details: Optional[dict] = None