
- Setup project structure and dependencies - Create Todo model and SQLAlchemy database connection - Set up Alembic for database migrations - Implement CRUD operations and API endpoints - Add health check endpoint - Update README with project documentation generated with BackendIM... (backend.im)
33 lines
902 B
Python
33 lines
902 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
"""Base Todo schema with common attributes."""
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
description: Optional[str] = Field(None, max_length=1000)
|
|
completed: Optional[bool] = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
"""Schema for creating a new Todo."""
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
"""Schema for updating a Todo."""
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
description: Optional[str] = Field(None, max_length=1000)
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoResponse(TodoBase):
|
|
"""Schema for Todo response including all fields."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
"""Configure response schema to use orm mode."""
|
|
orm_mode = True |