25 lines
551 B
Python
25 lines
551 B
Python
|
|
from pydantic import BaseModel
|
||
|
|
from typing import Optional
|
||
|
|
|
||
|
|
class ProductBase(BaseModel):
|
||
|
|
name: str
|
||
|
|
description: Optional[str] = None
|
||
|
|
price: float
|
||
|
|
stock: int = 0
|
||
|
|
|
||
|
|
class ProductCreate(ProductBase):
|
||
|
|
pass
|
||
|
|
|
||
|
|
class ProductUpdate(BaseModel):
|
||
|
|
name: Optional[str] = None
|
||
|
|
description: Optional[str] = None
|
||
|
|
price: Optional[float] = None
|
||
|
|
stock: Optional[int] = None
|
||
|
|
is_available: Optional[bool] = None
|
||
|
|
|
||
|
|
class ProductResponse(ProductBase):
|
||
|
|
id: int
|
||
|
|
is_available: bool
|
||
|
|
|
||
|
|
class Config:
|
||
|
|
from_attributes = True
|