from pydantic import BaseModel, Field, PositiveFloat, PositiveInt # Base schema class ProductBase(BaseModel): name: str = Field(..., description="Product name") description: str | None = Field(None, description="Product description") price: PositiveFloat = Field(..., description="Product price") stock_quantity: PositiveInt = Field(..., description="Product stock quantity") # Create schema class ProductCreate(ProductBase): pass class Config: schema_extra = { "example": { "name": "Product X", "description": "This is a description of Product X", "price": 9.99, "stock_quantity": 100 } } # Response schema class Product(ProductBase): id: int class Config: orm_mode = True