
- Set up FastAPI project structure - Configure SQLAlchemy with SQLite - Create Todo model and schemas - Implement CRUD operations - Add API endpoints for Todo management - Configure Alembic for database migrations - Add health check endpoint - Add comprehensive documentation
46 lines
808 B
Python
46 lines
808 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
"""Base schema for Todo"""
|
|
|
|
title: str
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
"""Schema for creating a new Todo"""
|
|
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
"""Schema for updating a Todo (all fields optional)"""
|
|
|
|
title: Optional[str] = None
|
|
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:
|
|
"""Configure pydantic model"""
|
|
|
|
from_attributes = True
|
|
|
|
|
|
class TodoResponse(TodoInDB):
|
|
"""Schema for Todo response"""
|
|
|
|
pass
|