-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.py
More file actions
90 lines (57 loc) · 1.99 KB
/
schemas.py
File metadata and controls
90 lines (57 loc) · 1.99 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
88
89
90
"""
Pydantic schemas for request and response models.
Defines data validation and serialization for API endpoints.
"""
from datetime import datetime
from typing import List
from pydantic import BaseModel, EmailStr, Field
class UserRegistration(BaseModel):
"""Schema for user registration request."""
email: EmailStr = Field(..., description="User email address")
username: str = Field(..., min_length=3, max_length=50, description="Username")
password: str = Field(..., min_length=6, description="User password")
class UserLogin(BaseModel):
"""Schema for user login request."""
email: EmailStr = Field(..., description="User email address")
password: str = Field(..., description="User password")
class UserResponse(BaseModel):
"""Schema for user information response."""
id: int
email: str
username: str
created_at: datetime
class Config:
from_attributes = True
class TokenResponse(BaseModel):
"""Schema for authentication token response."""
access_token: str
token_type: str = "bearer"
user: UserResponse
class ConceptResponse(BaseModel):
"""Schema for concept explanation response."""
concept: str
explanation: str
class HistoryEntryResponse(BaseModel):
"""Schema for history entry response."""
id: int
concept: str
explanation: str
created_at: datetime
class Config:
from_attributes = True
class HistoryListResponse(BaseModel):
"""Schema for history list response."""
entries: List[HistoryEntryResponse]
total: int
class SaveHistoryRequest(BaseModel):
"""Schema for saving history entry request."""
concept: str = Field(..., description="Concept name")
explanation: str = Field(..., description="Concept explanation")
class MessageResponse(BaseModel):
"""Schema for simple message responses."""
message: str
success: bool = True
class ErrorResponse(BaseModel):
"""Schema for error responses."""
detail: str
success: bool = False