Automated Action d2b80dacc4 Implement Shopping Cart and Checkout API
- Set up FastAPI application structure
- Create database models for User, Product, Cart, CartItem, Order, and OrderItem
- Set up Alembic for database migrations
- Create Pydantic schemas for request/response models
- Implement API endpoints for products, cart operations, and checkout process
- Add health endpoint
- Update README with project details and documentation
2025-05-18 00:00:02 +00:00

47 lines
1.2 KiB
Python

from typing import Optional
from decimal import Decimal
from pydantic import Field, HttpUrl
from app.schemas.base import BaseSchema, TimestampSchema
class ProductBase(BaseSchema):
"""Base schema for Product data."""
name: str
description: Optional[str] = None
price: Decimal = Field(..., ge=0, decimal_places=2)
sku: str
stock_quantity: int = Field(..., ge=0)
is_active: bool = True
image_url: Optional[HttpUrl] = None
class ProductCreate(ProductBase):
"""Schema for creating a new product."""
pass
class ProductUpdate(BaseSchema):
"""Schema for updating a product."""
name: Optional[str] = None
description: Optional[str] = None
price: Optional[Decimal] = Field(None, ge=0, decimal_places=2)
sku: Optional[str] = None
stock_quantity: Optional[int] = Field(None, ge=0)
is_active: Optional[bool] = None
image_url: Optional[HttpUrl] = None
class ProductInDBBase(ProductBase, TimestampSchema):
"""Base schema for Product in DB (with ID)."""
id: int
class Product(ProductInDBBase):
"""Schema for Product response."""
pass
class ProductInDB(ProductInDBBase):
"""Schema for Product in DB."""
pass