2025-05-26 19:04:54 +00:00

42 lines
728 B
Python

from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from pydantic import BaseModel
T = TypeVar("T")
class ResponseBase(BaseModel):
"""
Base response schema.
"""
success: bool = True
message: str = "Operation successful"
class DataResponse(ResponseBase, Generic[T]):
"""
Response schema with data.
"""
data: T
class ErrorResponse(ResponseBase):
"""
Error response schema.
"""
success: bool = False
message: str = "An error occurred"
error_details: Optional[Union[List[Dict[str, Any]], Dict[str, Any], str]] = None
class HealthResponse(BaseModel):
"""
Health check response schema.
"""
status: str = "ok"
version: str