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
58 lines (36 loc) · 1.62 KB
/
Copy pathschemas.py
File metadata and controls
58 lines (36 loc) · 1.62 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
from datetime import datetime
from pydantic import BaseModel, Field
class ErrorResponse(BaseModel):
code: str = Field(..., description="Machine-readable error code")
message: str = Field(..., description="Human-readable error message")
details: dict | None = Field(None, description="Optional additional error context")
class PostBase(BaseModel):
username: str = Field(..., min_length=1, examples=["alice"])
content: str = Field(..., min_length=1, examples=["Hello Contoso community!"])
class NewPost(PostBase):
pass
class UpdatePost(PostBase):
pass
class Post(PostBase):
id: str = Field(..., pattern=r"^[A-Za-z0-9_-]+$", examples=["p_123abc"])
createdAt: datetime = Field(..., examples=["2025-05-30T12:34:56Z"])
updatedAt: datetime = Field(..., examples=["2025-05-30T12:34:56Z"])
likes: int = Field(..., ge=0, examples=[3])
class Config:
from_attributes = True
class CommentBase(BaseModel):
username: str = Field(..., min_length=1, examples=["bob"])
content: str = Field(..., min_length=1, examples=["Nice post!"])
class NewComment(CommentBase):
pass
class UpdateComment(CommentBase):
pass
class Comment(CommentBase):
id: str = Field(..., pattern=r"^[A-Za-z0-9_-]+$", examples=["c_123abc"])
postId: str = Field(..., pattern=r"^[A-Za-z0-9_-]+$", examples=["p_123abc"])
createdAt: datetime = Field(..., examples=["2025-05-30T12:34:56Z"])
updatedAt: datetime = Field(..., examples=["2025-05-30T12:34:56Z"])
class Config:
from_attributes = True
class LikeRequest(BaseModel):
username: str = Field(..., min_length=1, examples=["alice"])