Automated Action 413eb37e87 Add simple todo app using FastAPI and SQLite
- Implement Todo database model with SQLAlchemy
- Set up Alembic for database migrations
- Create CRUD operations for Todo items
- Implement RESTful API endpoints
- Add health check endpoint
- Include comprehensive README with usage instructions
2025-05-17 21:39:34 +00:00

38 lines
1.1 KiB
Python

from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
class TodoBase(BaseModel):
"""Base Pydantic schema for Todo items."""
title: str = Field(..., min_length=1, max_length=100, description="Title of the todo item")
description: Optional[str] = Field(None, max_length=500, description="Optional description of the todo item")
class TodoCreate(TodoBase):
"""Pydantic schema for creating Todo items."""
pass
class TodoUpdate(BaseModel):
"""Pydantic schema for updating Todo items."""
title: Optional[str] = Field(None, min_length=1, max_length=100, description="Title of the todo item")
description: Optional[str] = Field(None, max_length=500, description="Description of the todo item")
completed: Optional[bool] = Field(None, description="Whether the todo is completed")
class TodoRead(TodoBase):
"""Pydantic schema for reading Todo items."""
id: int
completed: bool
created_at: datetime
updated_at: datetime
class Config:
"""Pydantic config for TodoRead."""
from_attributes = True