Automated Action 3bed1d0510 Create Todo API with FastAPI and SQLite
- Implement Todo CRUD API endpoints
- Set up SQLite database with SQLAlchemy
- Create Todo model and schemas
- Configure Alembic migrations
- Add comprehensive documentation

🤖 Generated with and Co-Authored by [BackendIM](https://backend.im)
2025-05-11 18:30:32 +00:00

38 lines
792 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
# Base Todo Schema for shared properties
class TodoBase(BaseModel):
title: str = Field(..., min_length=1, max_length=100)
description: Optional[str] = None
completed: Optional[bool] = False
# Schema for creating a todo
class TodoCreate(TodoBase):
pass
# Schema for updating a todo
class TodoUpdate(BaseModel):
title: Optional[str] = Field(None, min_length=1, max_length=100)
description: Optional[str] = None
completed: Optional[bool] = None
# Schema for returning a todo
class TodoInDB(TodoBase):
id: int
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True
# Schema for public API
class Todo(TodoInDB):
pass