Spaces:
Sleeping
Sleeping
| """ | |
| Base schemas for API requests and responses with projection_list support. | |
| """ | |
| from typing import Optional, List, Dict, Any, Generic, TypeVar | |
| from pydantic import BaseModel, Field | |
| T = TypeVar('T') | |
| class BaseLazyFetchSchema(BaseModel): | |
| """ | |
| Base schema for list/fetch endpoints with projection_list support. | |
| All list endpoints MUST extend this schema to ensure API standard compliance. | |
| """ | |
| filters: Optional[Dict[str, Any]] = Field( | |
| default=None, | |
| description="MongoDB query filters" | |
| ) | |
| skip: int = Field( | |
| default=0, | |
| ge=0, | |
| description="Number of documents to skip" | |
| ) | |
| limit: int = Field( | |
| default=100, | |
| ge=1, | |
| le=1000, | |
| description="Maximum number of documents to return" | |
| ) | |
| projection_list: Optional[List[str]] = Field( | |
| default=None, | |
| description="List of fields to include in response (API List Endpoint Standard)" | |
| ) | |
| class HealthResponse(BaseModel): | |
| """Health check response""" | |
| status: str | |
| service: str | |
| version: str | |
| class StandardResponse(BaseModel, Generic[T]): | |
| """Standard API response wrapper""" | |
| success: bool | |
| message: str | |
| data: Optional[T] = None | |