from typing import Generic, List, TypeVar from pydantic import BaseModel, Field T = TypeVar("T") class HealthCheck(BaseModel): """Health check response schema.""" status: str = "ok" message: str = "Application is healthy" class ErrorResponse(BaseModel): """Error response schema.""" detail: str class PaginationParams(BaseModel): """Pagination parameters schema.""" skip: int = Field(0, ge=0, description="Number of items to skip") limit: int = Field(100, gt=0, le=1000, description="Maximum number of items to return") class PaginatedResponse(BaseModel, Generic[T]): """Paginated response schema.""" items: List[T] total: int page: int pages: int @classmethod def create( cls, items: List[T], total: int, skip: int = 0, limit: int = 100 ) -> "PaginatedResponse[T]": """Create a paginated response.""" page = skip // limit + 1 if limit > 0 else 1 pages = (total + limit - 1) // limit if limit > 0 else 1 return cls( items=items, total=total, page=page, pages=pages, )