Automated Action 1b1f93e10f Create Todo application with FastAPI and SQLite
- Set up project structure with FastAPI
- Create Todo database model and schema
- Implement database connection with SQLAlchemy
- Set up Alembic migrations
- Implement CRUD API endpoints for Todo items
- Add health check endpoint
- Update documentation in README.md

generated with BackendIM... (backend.im)
2025-05-12 05:45:11 +00:00

37 lines
1.2 KiB
Python

from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
class TodoBase(BaseModel):
"""
Base schema for Todo items with common attributes.
"""
title: str = Field(..., min_length=1, max_length=100, description="Title of the todo item")
description: Optional[str] = Field(None, max_length=500, description="Detailed description of the todo item")
completed: bool = Field(False, description="Whether the todo item has been completed")
class TodoCreate(TodoBase):
"""
Schema for creating new Todo items.
"""
pass
class TodoUpdate(BaseModel):
"""
Schema for updating existing Todo items.
All fields are optional to allow partial updates.
"""
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="Detailed description of the todo item")
completed: Optional[bool] = Field(None, description="Whether the todo item has been completed")
class TodoResponse(TodoBase):
"""
Schema for returning Todo items in API responses.
"""
id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True