
- Set up project structure with FastAPI and SQLAlchemy - Create Todo model, schemas, and CRUD operations - Add API endpoints for todo operations (create, read, update, delete) - Set up Alembic for database migrations - Add health check endpoint - Update README with detailed instructions generated with BackendIM... (backend.im)
24 lines
710 B
Python
24 lines
710 B
Python
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 |