
- Set up project structure - Configure SQLAlchemy models and database connection - Set up Alembic for database migrations - Create Pydantic schemas for API data validation - Implement task CRUD operations - Add task filtering and pagination - Include health check endpoint - Update README with setup and usage instructions
38 lines
953 B
Python
38 lines
953 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TaskBase(BaseModel):
|
|
"""Base Task schema with shared attributes."""
|
|
title: str
|
|
description: Optional[str] = None
|
|
status: Optional[str] = "pending"
|
|
priority: Optional[str] = "medium"
|
|
due_date: Optional[datetime] = None
|
|
completed: Optional[bool] = False
|
|
|
|
|
|
class TaskCreate(TaskBase):
|
|
"""Schema for creating a new task."""
|
|
pass
|
|
|
|
|
|
class TaskUpdate(BaseModel):
|
|
"""Schema for updating an existing task."""
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
status: Optional[str] = None
|
|
priority: Optional[str] = None
|
|
due_date: Optional[datetime] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TaskResponse(TaskBase):
|
|
"""Schema for task responses with database fields."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True |