Automated Action 9505ec13a1 Implement simple todo application with FastAPI and SQLite
- Set up project structure and FastAPI app
- Create database models and SQLAlchemy connection
- Implement Alembic migration scripts
- Add CRUD API endpoints for Todo items
- Add health check endpoint
- Set up validation, error handling, and middleware
- Add comprehensive documentation in README.md
2025-05-18 12:42:38 +00:00

37 lines
1.2 KiB
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, constr
class TodoBase(BaseModel):
title: constr(min_length=1, max_length=100) = Field(..., description="The title of the todo item")
description: Optional[constr(max_length=500)] = Field(None, description="A detailed description of the todo item")
completed: bool = Field(False, description="Whether the todo item is completed")
class TodoCreate(TodoBase):
pass
class TodoUpdate(BaseModel):
title: Optional[constr(min_length=1, max_length=100)] = Field(None, description="The title of the todo item")
description: Optional[constr(max_length=500)] = Field(None, description="A detailed description of the todo item")
completed: Optional[bool] = Field(None, description="Whether the todo item is completed")
class TodoInDBBase(TodoBase):
id: int = Field(..., description="The unique identifier of the todo item")
created_at: datetime = Field(..., description="When the todo item was created")
updated_at: datetime = Field(..., description="When the todo item was last updated")
class Config:
from_attributes = True
class Todo(TodoInDBBase):
pass
class TodoInDB(TodoInDBBase):
pass