2025-03-27 12:19:27 +01:00

27 lines
932 B
Python

from pydantic import BaseModel, Field
from typing import Optional
# Base schema
class MealBase(BaseModel):
name: str = Field(..., index=True, description="Name of the meal")
description: Optional[str] = Field(None, description="Description of the meal")
price: float = Field(..., description="Price of the meal")
category: Optional[str] = Field(None, index=True, description="Category of the meal")
is_available: bool = Field(True, description="Availability status of the meal")
# Create schema
class MealCreate(MealBase):
pass
# Response schema
class Meal(MealBase):
class Config:
schema_extra = {
"example": {
"name": "Margherita Pizza",
"description": "Classic Italian pizza with tomato sauce, mozzarella, and basil",
"price": 9.99,
"category": "Pizza",
"is_available": True
}
}