feat(api): Pydantic schemas + Data Repositories
This commit is contained in:
20
app/schemas/common.py
Normal file
20
app/schemas/common.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""Common schemas used across the API."""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class CursorParams(BaseModel):
|
||||
"""Pagination parameters using cursor-based pagination."""
|
||||
|
||||
cursor: str | None = Field(default=None, description="Cursor for pagination")
|
||||
limit: int = Field(default=20, ge=1, le=100, description="Number of items per page")
|
||||
|
||||
|
||||
class PaginatedResponse[T](BaseModel):
|
||||
"""Generic paginated response wrapper."""
|
||||
|
||||
items: list[T]
|
||||
next_cursor: str | None = Field(
|
||||
default=None, description="Cursor for next page, null if no more items"
|
||||
)
|
||||
has_more: bool = Field(description="Whether there are more items")
|
||||
Reference in New Issue
Block a user