From 5cd6b68273ba12f936bdfb7e73fcc0b5ffeb0582 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 13:31:49 +0000 Subject: [PATCH] Add Soap schema --- schemas/soap.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 schemas/soap.py diff --git a/schemas/soap.py b/schemas/soap.py new file mode 100644 index 0000000..71381f0 --- /dev/null +++ b/schemas/soap.py @@ -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 \ No newline at end of file