from pydantic import BaseModel, Field from typing import Optional from datetime import datetime class TodoBase(BaseModel): title: str = Field(..., max_length=100, example="Buy groceries") description: Optional[str] = Field(None, example="Milk, bread, eggs, cheese") class TodoCreate(TodoBase): pass class TodoUpdate(BaseModel): title: Optional[str] = Field(None, max_length=100, example="Buy more groceries") description: Optional[str] = Field(None, example="Update shopping list") completed: Optional[bool] = Field(None, example=True) class Todo(TodoBase): id: int completed: bool created_at: datetime updated_at: datetime class Config: orm_mode = True