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 } }