Add User schema
This commit is contained in:
parent
0cc30c9757
commit
93152162aa
49
schemas/user.py
Normal file
49
schemas/user.py
Normal file
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user