refactor(backend): ♻️ Split Recipe Schema Code

This commit is contained in:
hay-kot
2021-08-27 20:17:41 -08:00
parent 5ba337ab11
commit 0675c570ce
25 changed files with 494 additions and 120 deletions

View File

@@ -0,0 +1,39 @@
from typing import Optional, Union
from fastapi_camelcase import CamelModel
class CreateIngredientFood(CamelModel):
name: str
description: str = ""
class CreateIngredientUnit(CreateIngredientFood):
fraction: bool = True
abbreviation: str = ""
class IngredientFood(CreateIngredientFood):
id: int
class Config:
orm_mode = True
class IngredientUnit(CreateIngredientUnit):
id: int
class Config:
orm_mode = True
class RecipeIngredient(CamelModel):
title: Optional[str]
note: Optional[str]
unit: Optional[Union[CreateIngredientUnit, IngredientUnit]]
food: Optional[Union[CreateIngredientFood, IngredientFood]]
disable_amount: bool = True
quantity: float = 1
class Config:
orm_mode = True