Add initial project configuration and setup for Reference Board Viewer application. Include EditorConfig for consistent coding styles, pre-commit hooks for linting and formatting, Docker Compose for local development with PostgreSQL and MinIO, and a Nix flake for development environment management. Establish CI/CD pipeline for automated testing and deployment.
This commit is contained in:
64
backend/app/core/schemas.py
Normal file
64
backend/app/core/schemas.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""Base Pydantic schemas."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class BaseSchema(BaseModel):
|
||||
"""Base schema with common configuration."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
from_attributes=True,
|
||||
populate_by_name=True,
|
||||
json_schema_extra={
|
||||
"example": {}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class TimestampSchema(BaseSchema):
|
||||
"""Schema with timestamp fields."""
|
||||
|
||||
created_at: datetime = Field(..., description="Creation timestamp")
|
||||
updated_at: datetime | None = Field(None, description="Last update timestamp")
|
||||
|
||||
|
||||
class IDSchema(BaseSchema):
|
||||
"""Schema with ID field."""
|
||||
|
||||
id: UUID = Field(..., description="Unique identifier")
|
||||
|
||||
|
||||
class ResponseSchema(BaseSchema):
|
||||
"""Generic response schema."""
|
||||
|
||||
message: str = Field(..., description="Response message")
|
||||
data: dict[str, Any] | None = Field(None, description="Response data")
|
||||
|
||||
|
||||
class ErrorSchema(BaseSchema):
|
||||
"""Error response schema."""
|
||||
|
||||
error: str = Field(..., description="Error message")
|
||||
details: dict[str, Any] | None = Field(None, description="Error details")
|
||||
status_code: int = Field(..., description="HTTP status code")
|
||||
|
||||
|
||||
class PaginationSchema(BaseSchema):
|
||||
"""Pagination metadata schema."""
|
||||
|
||||
total: int = Field(..., description="Total number of items")
|
||||
page: int = Field(..., description="Current page number")
|
||||
page_size: int = Field(..., description="Items per page")
|
||||
total_pages: int = Field(..., description="Total number of pages")
|
||||
|
||||
|
||||
class PaginatedResponse(BaseSchema):
|
||||
"""Paginated response schema."""
|
||||
|
||||
items: list[Any] = Field(..., description="List of items")
|
||||
pagination: PaginationSchema = Field(..., description="Pagination metadata")
|
||||
|
||||
Reference in New Issue
Block a user