
- Setup project structure with FastAPI - Create Todo model and database schemas - Implement CRUD operations for Todo items - Create API endpoints for Todo operations - Add health check endpoint - Configure Alembic for database migrations - Add detailed documentation in README.md
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.models.todo import TodoPriority
|
|
|
|
|
|
# Shared properties
|
|
class TodoBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=255, description="Title of the todo item")
|
|
description: Optional[str] = Field(None, max_length=1000, description="Detailed description of the todo item")
|
|
priority: TodoPriority = Field(TodoPriority.MEDIUM, description="Priority level of the todo item")
|
|
completed: bool = Field(False, description="Whether the todo item is completed")
|
|
|
|
|
|
# Properties to receive on todo creation
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on todo update
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255, description="Title of the todo item")
|
|
description: Optional[str] = Field(None, max_length=1000, description="Detailed description of the todo item")
|
|
priority: Optional[TodoPriority] = Field(None, description="Priority level of the todo item")
|
|
completed: Optional[bool] = Field(None, description="Whether the todo item is completed")
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class TodoInDBBase(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Todo(TodoInDBBase):
|
|
pass
|