Spaces:
Running
Running
Commit ·
34cbfee
1
Parent(s): b7a3226
feat: add BaseLazyFetchSchema for pagination and projection support in list requests
Browse files- app/core/schemas.py +23 -1
app/core/schemas.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
Core/Common Pydantic schemas used across multiple modules.
|
| 3 |
These schemas provide reusable components for consistent API responses.
|
| 4 |
"""
|
| 5 |
-
from typing import Optional, Any, Dict
|
| 6 |
from datetime import datetime
|
| 7 |
from pydantic import BaseModel, Field
|
| 8 |
|
|
@@ -118,3 +118,25 @@ class StatusResponse(BaseModel):
|
|
| 118 |
}
|
| 119 |
}
|
| 120 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
Core/Common Pydantic schemas used across multiple modules.
|
| 3 |
These schemas provide reusable components for consistent API responses.
|
| 4 |
"""
|
| 5 |
+
from typing import Optional, Any, Dict, List
|
| 6 |
from datetime import datetime
|
| 7 |
from pydantic import BaseModel, Field
|
| 8 |
|
|
|
|
| 118 |
}
|
| 119 |
}
|
| 120 |
}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
class BaseLazyFetchSchema(BaseModel):
|
| 124 |
+
"""
|
| 125 |
+
Base schema for lazy-fetch list requests with pagination and projection support.
|
| 126 |
+
Provides common fields for listing endpoints with filtering, pagination, and field projection.
|
| 127 |
+
"""
|
| 128 |
+
skip: int = Field(0, ge=0, description="Number of records to skip (pagination offset)")
|
| 129 |
+
limit: int = Field(100, ge=1, le=500, description="Maximum number of records to return")
|
| 130 |
+
projection_list: Optional[List[str]] = Field(
|
| 131 |
+
None,
|
| 132 |
+
description="List of fields to include in response (omit for all fields)"
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
class Config:
|
| 136 |
+
json_schema_extra = {
|
| 137 |
+
"example": {
|
| 138 |
+
"skip": 0,
|
| 139 |
+
"limit": 100,
|
| 140 |
+
"projection_list": ["id", "name", "status"]
|
| 141 |
+
}
|
| 142 |
+
}
|