Add Soap schema
This commit is contained in:
parent
26e7ab0301
commit
5cd6b68273
38
schemas/soap.py
Normal file
38
schemas/soap.py
Normal file
@ -0,0 +1,38 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
from decimal import Decimal
|
||||
|
||||
class SoapBase(BaseModel):
|
||||
name: str = Field(..., index=True, min_length=1, max_length=100)
|
||||
brand: str = Field(..., min_length=1, max_length=100)
|
||||
description: Optional[str] = None
|
||||
price: Decimal = Field(..., ge=0, decimal_places=2)
|
||||
weight: Decimal = Field(..., ge=0, decimal_places=2)
|
||||
ingredients: Optional[str] = None
|
||||
stock_quantity: int = Field(default=0, ge=0)
|
||||
is_available: bool = Field(default=True)
|
||||
fragrance: Optional[str] = None
|
||||
type: Optional[str] = None
|
||||
|
||||
class SoapCreate(SoapBase):
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "Lavender Dreams",
|
||||
"brand": "Natural Care",
|
||||
"description": "Relaxing lavender soap bar",
|
||||
"price": "5.99",
|
||||
"weight": "100.00",
|
||||
"ingredients": "Coconut oil, lavender essential oil, sodium hydroxide",
|
||||
"stock_quantity": 100,
|
||||
"is_available": True,
|
||||
"fragrance": "Lavender",
|
||||
"type": "Bar soap"
|
||||
}
|
||||
}
|
||||
|
||||
class Soap(SoapBase):
|
||||
id: int = Field(..., gt=0)
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
Loading…
x
Reference in New Issue
Block a user