
- Set up project structure and dependencies - Create database models with SQLAlchemy - Implement API endpoints for CRUD operations - Set up Alembic for database migrations - Add health check endpoint - Configure Ruff for linting - Update documentation in README
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
"""Base schema for Item with common attributes."""
|
|
|
|
title: str = Field(..., min_length=1, max_length=100, description="Item title")
|
|
description: Optional[str] = Field(None, description="Optional item description")
|
|
is_active: bool = Field(True, description="Item status")
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
"""Schema for creating a new Item."""
|
|
|
|
pass
|
|
|
|
|
|
class ItemUpdate(BaseModel):
|
|
"""Schema for updating an existing Item."""
|
|
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100, description="Item title")
|
|
description: Optional[str] = Field(None, description="Optional item description")
|
|
is_active: Optional[bool] = Field(None, description="Item status")
|
|
|
|
|
|
class ItemInDBBase(ItemBase):
|
|
"""Base schema for Item as stored in DB with ID and timestamps."""
|
|
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Item(ItemInDBBase):
|
|
"""Schema for returning an Item."""
|
|
|
|
pass
|