e62ece1c06
- FastAPI app with CORS, lifespan handlers - Pydantic Settings config (DB, Redis, CORS, SMTP, JWT, Rentman) - SQLAlchemy async engine + session (DeclarativeBase) - 6 DB models: EquipmentCache, RentalRequest, RentalRequestItem, Contact, AdminUser, SyncLog - Pydantic schemas: EquipmentItem, EquipmentDetail, PaginatedEquipment, ContactCreate, ContactResponse - Redis cache helper: set/get/delete_pattern, rate limiting, equipment key builders - Equipment router: list (search/category/sort/pagination), detail, categories – all cached - Contact router: POST with Pydantic validation + rate limiting (5/min) - Health router: GET /api/health with DB + Redis status - 28 pytest tests (all pass, 90% coverage) - Dockerfile, requirements.txt, pytest.ini, test_report.md
51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
"""Pydantic schemas for equipment endpoints."""
|
|
|
|
from decimal import Decimal
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class EquipmentItem(BaseModel):
|
|
"""Equipment item for list responses."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
rentman_id: str
|
|
name: str
|
|
number: str | None = None
|
|
category: str | None = None
|
|
description: str | None = None
|
|
image_url: str | None = None
|
|
rental_price: Decimal | None = None
|
|
available: bool = True
|
|
|
|
|
|
class EquipmentDetail(BaseModel):
|
|
"""Equipment detail with full specifications."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
rentman_id: str
|
|
name: str
|
|
number: str | None = None
|
|
category: str | None = None
|
|
subcategory: str | None = None
|
|
description: str | None = None
|
|
specifications: dict | None = None
|
|
images: list | None = None
|
|
rental_price: Decimal | None = None
|
|
brand: str | None = None
|
|
available: bool = True
|
|
|
|
|
|
class PaginatedEquipment(BaseModel):
|
|
"""Paginated response for equipment list."""
|
|
|
|
items: list[EquipmentItem]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
total_pages: int
|