diff --git a/schemas/user.py b/schemas/user.py new file mode 100644 index 0000000..0582342 --- /dev/null +++ b/schemas/user.py @@ -0,0 +1,49 @@ +from pydantic import BaseModel, Field +from typing import Optional + +class UserBase(BaseModel): + name: str = Field(..., index=True, description="Product name") + brand: str = Field(..., description="Product brand") + category: str = Field(..., description="Product category") + size: str = Field(..., description="Product size") + color: str = Field(..., description="Product color") + price: float = Field(..., gt=0, description="Product price") + description: Optional[str] = Field(None, description="Product description") + stock_quantity: int = Field(default=0, ge=0, description="Available stock quantity") + is_available: bool = Field(default=True, description="Product availability status") + +class UserCreate(UserBase): + class Config: + schema_extra = { + "example": { + "name": "Classic T-Shirt", + "brand": "BrandName", + "category": "Clothing", + "size": "M", + "color": "Blue", + "price": 29.99, + "description": "Comfortable cotton t-shirt", + "stock_quantity": 100, + "is_available": True + } + } + +class User(UserBase): + id: int = Field(..., description="Product ID") + + class Config: + orm_mode = True + schema_extra = { + "example": { + "id": 1, + "name": "Classic T-Shirt", + "brand": "BrandName", + "category": "Clothing", + "size": "M", + "color": "Blue", + "price": 29.99, + "description": "Comfortable cotton t-shirt", + "stock_quantity": 100, + "is_available": True + } + } \ No newline at end of file