
- Created project structure and FastAPI application - Added SQLite database models and Pydantic schemas - Implemented todo routes (add, list, delete) - Set up Alembic migrations - Added health endpoint generated with BackendIM... (backend.im)
34 lines
650 B
Python
34 lines
650 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
class TodoBase(BaseModel):
|
|
"""
|
|
Base schema for Todo items
|
|
"""
|
|
title: str
|
|
|
|
class TodoCreate(TodoBase):
|
|
"""
|
|
Schema for creating a new Todo
|
|
"""
|
|
pass
|
|
|
|
class TodoUpdate(BaseModel):
|
|
"""
|
|
Schema for updating an existing Todo
|
|
"""
|
|
title: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
class TodoResponse(TodoBase):
|
|
"""
|
|
Schema for Todo response from API
|
|
"""
|
|
id: int
|
|
completed: bool
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
orm_mode = True |