
- Set up project structure and FastAPI application - Create database models with SQLAlchemy - Set up Alembic for database migrations - Create API endpoints for todo CRUD operations - Add health check endpoint - Add unit tests for API endpoints - Configure Ruff for linting and formatting
44 lines
834 B
Python
44 lines
834 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
"""Base schema for Todo."""
|
|
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
"""Schema for creating a Todo."""
|
|
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
"""Schema for updating a Todo."""
|
|
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoInDB(TodoBase):
|
|
"""Schema for Todo stored in DB."""
|
|
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class TodoResponse(TodoInDB):
|
|
"""Schema for Todo response."""
|
|
|
|
pass
|