Add Meal schema
This commit is contained in:
parent
4d31e63cb8
commit
df5a735b42
@ -1,18 +1,33 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field, validator
|
||||
from typing import Optional, Union
|
||||
|
||||
class MealBase(BaseModel):
|
||||
name: str = Field(..., description="Name of the meal")
|
||||
description: Optional[str] = Field(None, description="Description of the meal")
|
||||
price: float = Field(..., gt=0, description="Price of the meal")
|
||||
category_id: UUID = Field(..., description="ID of the category the meal belongs to")
|
||||
is_available: bool = Field(True, description="Availability status of the meal")
|
||||
category: Optional[str] = Field(None, description="Category of the meal")
|
||||
cuisine: Optional[str] = Field(None, description="Cuisine of the meal")
|
||||
dietary_restrictions: Optional[dict] = Field(None, description="Dietary restrictions for the meal")
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "Margherita Pizza",
|
||||
"description": "Classic Italian pizza with tomato sauce, mozzarella cheese, and fresh basil",
|
||||
"price": 12.99,
|
||||
"is_available": True,
|
||||
"category": "Pizza",
|
||||
"cuisine": "Italian",
|
||||
"dietary_restrictions": {"vegetarian": True, "nut_free": True}
|
||||
}
|
||||
}
|
||||
|
||||
class MealCreate(MealBase):
|
||||
pass
|
||||
|
||||
class MealResponse(MealBase):
|
||||
id: UUID = Field(..., description="ID of the meal")
|
||||
id: int = Field(..., description="Unique identifier for the meal")
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
Loading…
x
Reference in New Issue
Block a user