
- 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
39 lines
920 B
Python
39 lines
920 B
Python
from typing import Optional
|
|
from pydantic import EmailStr, Field
|
|
|
|
from app.schemas.base import BaseSchema, TimestampSchema
|
|
|
|
|
|
class UserBase(BaseSchema):
|
|
"""Base schema for User data."""
|
|
email: EmailStr
|
|
full_name: Optional[str] = None
|
|
is_active: bool = True
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
"""Schema for creating a new user."""
|
|
password: str = Field(..., min_length=8)
|
|
|
|
|
|
class UserUpdate(BaseSchema):
|
|
"""Schema for updating a user."""
|
|
email: Optional[EmailStr] = None
|
|
full_name: Optional[str] = None
|
|
password: Optional[str] = Field(None, min_length=8)
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class UserInDBBase(UserBase, TimestampSchema):
|
|
"""Base schema for User in DB (with ID)."""
|
|
id: int
|
|
|
|
|
|
class User(UserInDBBase):
|
|
"""Schema for User response."""
|
|
pass
|
|
|
|
|
|
class UserInDB(UserInDBBase):
|
|
"""Schema for User in DB (with hashed_password)."""
|
|
hashed_password: str |