41 lines
774 B
Python
41 lines
774 B
Python
"""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
|