mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-07 19:05:35 -05:00
48 lines
836 B
Python
48 lines
836 B
Python
from typing import List, Optional
|
|
|
|
from fastapi_camelcase import CamelModel
|
|
from pydantic.utils import GetterDict
|
|
|
|
|
|
class CategoryIn(CamelModel):
|
|
name: str
|
|
|
|
|
|
class CategoryBase(CategoryIn):
|
|
id: int
|
|
slug: str
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
@classmethod
|
|
def getter_dict(_cls, name_orm):
|
|
return {
|
|
**GetterDict(name_orm),
|
|
}
|
|
|
|
|
|
class RecipeCategoryResponse(CategoryBase):
|
|
recipes: Optional[List["Recipe"]]
|
|
|
|
class Config:
|
|
schema_extra = {"example": {"id": 1, "name": "dinner", "recipes": [{}]}}
|
|
|
|
|
|
class TagIn(CategoryIn):
|
|
pass
|
|
|
|
|
|
class TagBase(CategoryBase):
|
|
pass
|
|
|
|
|
|
class RecipeTagResponse(RecipeCategoryResponse):
|
|
pass
|
|
|
|
|
|
from .recipe import Recipe
|
|
|
|
RecipeCategoryResponse.update_forward_refs()
|
|
RecipeTagResponse.update_forward_refs()
|