diff --git a/schemas/flower.py b/schemas/flower.py new file mode 100644 index 0000000..e360335 --- /dev/null +++ b/schemas/flower.py @@ -0,0 +1,35 @@ +from pydantic import BaseModel, Field + +# Base schema +class FlowerBase(BaseModel): + name: str = Field(..., description="Name of the flower") + description: str | None = Field(None, description="Description of the flower") + color: str | None = Field(None, description="Color of the flower") + price: int = Field(..., description="Price of the flower") + +# Schema for creating a new Flower +class FlowerCreate(FlowerBase): + class Config: + schema_extra = { + "example": { + "name": "Rose", + "description": "A beautiful red flower", + "color": "red", + "price": 10 + } + } + +# Schema for Flower responses +class Flower(FlowerBase): + id: int + class Config: + orm_mode = True + schema_extra = { + "example": { + "id": 1, + "name": "Rose", + "description": "A beautiful red flower", + "color": "red", + "price": 10 + } + } \ No newline at end of file