fixed shopping list null handling

This commit is contained in:
Michael Genson 2024-02-19 15:43:59 +00:00
parent 2a016ecce9
commit fbfc5b31d6

View File

@ -225,10 +225,14 @@ class ShoppingListUpdate(ShoppingListSave):
class ShoppingListOut(ShoppingListUpdate):
recipe_references: list[ShoppingListRecipeRefOut]
label_settings: list[ShoppingListMultiPurposeLabelOut]
recipe_references: list[ShoppingListRecipeRefOut] = []
label_settings: list[ShoppingListMultiPurposeLabelOut] = []
model_config = ConfigDict(from_attributes=True)
@field_validator("recipe_references", "label_settings", mode="before")
def default_none_to_empty_list(cls, v):
return v or []
@classmethod
def loader_options(cls) -> list[LoaderOption]:
return [