
- Set up project structure with app modules - Configure SQLite database connection - Set up Alembic for database migrations - Implement Item model with CRUD operations - Create API endpoints for items management - Add health check endpoint - Add API documentation - Add comprehensive README
47 lines
924 B
Python
47 lines
924 B
Python
"""
|
|
Pydantic schemas for Item.
|
|
"""
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
"""Base schema for Item."""
|
|
title: str
|
|
description: Optional[str] = None
|
|
is_active: bool = True
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
"""Schema for creating a new Item."""
|
|
pass
|
|
|
|
|
|
class ItemUpdate(BaseModel):
|
|
"""Schema for updating an existing Item."""
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class ItemInDBBase(ItemBase):
|
|
"""Base schema for Item in DB."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
"""Pydantic config."""
|
|
from_attributes = True
|
|
|
|
|
|
class Item(ItemInDBBase):
|
|
"""Schema for Item used in response."""
|
|
pass
|
|
|
|
|
|
class ItemInDB(ItemInDBBase):
|
|
"""Schema for Item stored in DB."""
|
|
pass |