Automated Action 53bc4e0199 Implement Task Manager API
- Set up FastAPI application structure
- Create Task model with SQLAlchemy
- Implement CRUD operations for tasks
- Add API endpoints for tasks with filtering options
- Configure Alembic for database migrations
- Add health check endpoint
- Configure Ruff for linting
- Add comprehensive documentation in README.md
2025-06-10 14:48:01 +00:00

48 lines
1.6 KiB
Python

"""Task schemas for request/response validation."""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, ConfigDict, Field
class TaskBase(BaseModel):
"""Base schema for Task."""
title: str = Field(..., min_length=1, max_length=255, description="Title of the task")
description: Optional[str] = Field(None, description="Description of the task")
completed: bool = Field(False, description="Completion status of the task")
priority: int = Field(1, ge=1, le=3, description="Priority level: 1=Low, 2=Medium, 3=High")
due_date: Optional[datetime] = Field(None, description="Due date of the task")
class TaskCreate(TaskBase):
"""Schema for creating a new task."""
pass
class TaskUpdate(BaseModel):
"""Schema for updating an existing task."""
title: Optional[str] = Field(
None, min_length=1, max_length=255, description="Title of the task"
)
description: Optional[str] = Field(None, description="Description of the task")
completed: Optional[bool] = Field(None, description="Completion status of the task")
priority: Optional[int] = Field(
None, ge=1, le=3, description="Priority level: 1=Low, 2=Medium, 3=High"
)
due_date: Optional[datetime] = Field(None, description="Due date of the task")
model_config = ConfigDict(extra="forbid")
class Task(TaskBase):
"""Schema for Task model."""
id: int
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)
class TaskResponse(Task):
"""Schema for Task response."""
pass