forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.py
More file actions
73 lines (52 loc) · 1.43 KB
/
Copy pathschemas.py
File metadata and controls
73 lines (52 loc) · 1.43 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
from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional
# Post schemas
class CreatePostRequest(BaseModel):
username: str
content: str
class UpdatePostRequest(BaseModel):
username: str
content: str
class Post(BaseModel):
id: str
username: str
content: str
created_at: datetime = Field(alias="createdAt")
updated_at: datetime = Field(alias="updatedAt")
likes_count: int = Field(alias="likesCount")
comments_count: int = Field(alias="commentsCount")
class Config:
populate_by_name = True
from_attributes = True
# Comment schemas
class CreateCommentRequest(BaseModel):
username: str
content: str
class UpdateCommentRequest(BaseModel):
username: str
content: str
class Comment(BaseModel):
id: str
post_id: str = Field(alias="postId")
username: str
content: str
created_at: datetime = Field(alias="createdAt")
updated_at: datetime = Field(alias="updatedAt")
class Config:
populate_by_name = True
from_attributes = True
# Like schemas
class LikeRequest(BaseModel):
username: str
class Like(BaseModel):
post_id: str = Field(alias="postId")
username: str
created_at: datetime = Field(alias="createdAt")
class Config:
populate_by_name = True
from_attributes = True
# Error schema
class Error(BaseModel):
message: str
details: Optional[str] = None