
- Created FastAPI application with SQLite database - Implemented models for inventory items, categories, suppliers, and transactions - Added authentication system with JWT tokens - Implemented CRUD operations for all models - Set up Alembic for database migrations - Added comprehensive API documentation - Configured Ruff for code linting
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class CategoryBase(BaseModel):
|
|
"""
|
|
Base category schema with common attributes.
|
|
"""
|
|
name: str = Field(..., description="Category name")
|
|
description: Optional[str] = Field(None, description="Category description")
|
|
|
|
|
|
class CategoryCreate(CategoryBase):
|
|
"""
|
|
Schema for category creation.
|
|
"""
|
|
pass
|
|
|
|
|
|
class CategoryUpdate(BaseModel):
|
|
"""
|
|
Schema for updating category information.
|
|
"""
|
|
name: Optional[str] = Field(None, description="Category name")
|
|
description: Optional[str] = Field(None, description="Category description")
|
|
|
|
|
|
class CategoryInDBBase(CategoryBase):
|
|
"""
|
|
Base schema for categories from the database.
|
|
"""
|
|
id: int = Field(..., description="Category ID")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Category(CategoryInDBBase):
|
|
"""
|
|
Schema for category information returned to clients.
|
|
"""
|
|
pass
|
|
|
|
|
|
class CategoryWithItems(CategoryInDBBase):
|
|
"""
|
|
Schema for category with related items.
|
|
"""
|
|
from app.schemas.item import Item
|
|
items: List[Item] = Field([], description="Items in this category") |