Initial commit
This commit is contained in:
40
backend/app/schemas/common.py
Normal file
40
backend/app/schemas/common.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Common Pydantic schemas used across the application."""
|
||||
|
||||
from typing import Optional, Generic, TypeVar, List
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
DataT = TypeVar('DataT')
|
||||
|
||||
|
||||
class PaginatedResponse(BaseModel, Generic[DataT]):
|
||||
"""Generic paginated response schema."""
|
||||
|
||||
items: List[DataT]
|
||||
total: int
|
||||
page: int
|
||||
limit: int
|
||||
pages: int
|
||||
|
||||
|
||||
class MessageResponse(BaseModel):
|
||||
"""Simple message response schema."""
|
||||
|
||||
message: str
|
||||
detail: Optional[str] = None
|
||||
|
||||
|
||||
class ErrorResponse(BaseModel):
|
||||
"""Error response schema."""
|
||||
|
||||
error: str
|
||||
detail: Optional[str] = None
|
||||
status_code: int
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
"""JWT token response schema."""
|
||||
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
expires_in: int # seconds
|
||||
Reference in New Issue
Block a user