
- Set up FastAPI project structure with best practices - Implemented SQLAlchemy models with SQLite database - Added Alembic for database migrations - Created CRUD API endpoints for items - Added health check endpoint - Updated documentation generated with BackendIM... (backend.im)
30 lines
752 B
Python
30 lines
752 B
Python
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
class ItemBase(BaseModel):
|
|
"""Base schema for Item model."""
|
|
name: str
|
|
description: Optional[str] = None
|
|
|
|
class ItemCreate(ItemBase):
|
|
"""Schema for creating a new Item."""
|
|
pass
|
|
|
|
class ItemUpdate(ItemBase):
|
|
"""Schema for updating an existing Item."""
|
|
name: Optional[str] = None
|
|
|
|
class ItemInDBBase(ItemBase):
|
|
"""Base schema for Item with DB fields."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
"""Configure Pydantic to read data from an ORM model."""
|
|
from_attributes = True
|
|
|
|
class Item(ItemInDBBase):
|
|
"""Schema for retrieving Item data."""
|
|
pass |