
- Implement Todo model with SQLAlchemy - Create Pydantic schemas for request/response validation - Add complete CRUD API endpoints (/api/v1/todos) - Include proper error handling and HTTP status codes - Set up proper project structure with organized modules - All code linted and formatted with ruff
28 lines
519 B
Python
28 lines
519 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
title: str
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoResponse(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True |