{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:folio:1:recipes",
  "title": "recipes.json",
  "description": "Every recipe in the file. Required in every .folio file; may be an empty array.",
  "type": "array",
  "items": {
    "type": "object",
    "required": [
      "id",
      "title",
      "servings",
      "ingredients",
      "steps",
      "photo",
      "createdAt",
      "updatedAt"
    ],
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "description": "Stable and unique. Import merges by id: a recipe whose id is already there is left alone."
      },
      "title": {
        "type": "string",
        "minLength": 1
      },
      "description": {
        "type": "string"
      },
      "servings": {
        "type": "integer",
        "minimum": 1
      },
      "totalMinutes": {
        "type": "integer",
        "minimum": 0
      },
      "difficulty": {
        "enum": [
          "Easy",
          "Medium",
          "Hard"
        ],
        "description": "Missing: Easy."
      },
      "category": {
        "enum": [
          "Breakfast",
          "Lunch",
          "Dinner",
          "Snacks",
          "Baking"
        ],
        "description": "Missing: Dinner."
      },
      "tags": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "slots": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "Meal slot ids the recipe suits: breakfast, lunch, preworkout, dinner, or the cook's own."
      },
      "source": {
        "type": "object",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "enum": [
              "link",
              "text",
              "photo",
              "manual"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The site or book."
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "note": {
        "type": [
          "string",
          "null"
        ]
      },
      "createdAt": {
        "type": "string",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$",
        "description": "ISO 8601 in UTC with a Z, seconds required, fractions of a second optional (up to 9 digits): 2026-11-08T12:00:00Z."
      },
      "updatedAt": {
        "type": "string",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$",
        "description": "ISO 8601 in UTC with a Z, seconds required, fractions of a second optional (up to 9 digits): 2026-11-08T12:00:00Z."
      },
      "photo": {
        "type": "object",
        "required": [
          "tabletop",
          "plate",
          "food",
          "accents",
          "kind"
        ],
        "properties": {
          "tabletop": {
            "type": "string",
            "pattern": "^#[0-9A-Fa-f]{6}$"
          },
          "plate": {
            "type": "string",
            "pattern": "^#[0-9A-Fa-f]{6}$"
          },
          "food": {
            "type": "string",
            "pattern": "^#[0-9A-Fa-f]{6}$"
          },
          "accents": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^#[0-9A-Fa-f]{6}$"
            }
          },
          "kind": {
            "enum": [
              "file",
              "bundled",
              "unsplash",
              "none"
            ],
            "description": "file: an image inside the archive. bundled: one of the app's own sample photos. unsplash: shown from Unsplash, never copied. none: the drawn plate in the palette above."
          },
          "file": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^photos/[^/\\\\]+\\.(jpg|jpeg|png|heic|JPG|JPEG|PNG|HEIC)$",
            "description": "photos/<recipeId>.<jpg|png|heic> for file; the sample photo's path for bundled."
          },
          "unsplash": {
            "type": "object",
            "required": [
              "id",
              "rawUrl",
              "photographer"
            ],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              },
              "rawUrl": {
                "type": "string",
                "format": "uri"
              },
              "photographer": {
                "type": "string"
              },
              "photographerUrl": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "downloadTracked": {
                "type": "boolean"
              },
              "thumbUrl": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "downloadLocation": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "alt": {
            "type": [
              "string",
              "null"
            ]
          },
          "focus": {
            "type": "object",
            "required": [
              "x",
              "y"
            ],
            "properties": {
              "x": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "y": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              }
            },
            "description": "Where to centre a crop, 0–1 from the top left."
          },
          "origin": {
            "anyOf": [
              {
                "enum": [
                  "page",
                  "camera",
                  "library",
                  "unsplash",
                  "bundled"
                ],
                "description": "Where an own photo came from."
              },
              {
                "type": "null"
              }
            ]
          },
          "credit": {
            "type": "object",
            "required": [],
            "properties": {
              "photographer": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "photographerUrl": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "source": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "photoUrl": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "license": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "alt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "description": "Square photo, or the drawn plate when there is none. The palette is always needed: it is the placeholder while a photo loads.",
        "allOf": [
          {
            "if": {
              "properties": {
                "kind": {
                  "const": "file"
                }
              }
            },
            "then": {
              "required": [
                "file"
              ],
              "properties": {
                "file": {
                  "type": "string"
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "kind": {
                  "const": "unsplash"
                }
              }
            },
            "then": {
              "required": [
                "unsplash"
              ]
            }
          }
        ]
      },
      "ingredients": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "position",
            "name",
            "quantityText",
            "unit",
            "aisle",
            "confidence",
            "nutrition"
          ],
          "properties": {
            "position": {
              "type": "integer",
              "minimum": 1,
              "description": "1 for the first line."
            },
            "quantity": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "description": "The written amount as a number: ½ is 0.5. Null for \"to taste\"."
            },
            "quantityText": {
              "type": "string",
              "description": "The amount as written: \"½\", \"1–2\", \"400\". Empty when there is none."
            },
            "unit": {
              "type": "string",
              "description": "As written: g, ml, cup, tbsp, tsp, clove, … Empty for counts like \"2 eggs\"."
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "description": "As written in the recipe: \"spaghetti\"."
            },
            "note": {
              "type": [
                "string",
                "null"
              ],
              "description": "\"finely chopped\"."
            },
            "foodId": {
              "type": [
                "string",
                "null"
              ],
              "description": "The matched food (Shared/FoodData/foods.json id, or custom-… for the cook's own). Empty or null when unmatched. Lines with the same foodId merge on the grocery list."
            },
            "foodName": {
              "type": [
                "string",
                "null"
              ]
            },
            "state": {
              "type": [
                "string",
                "null"
              ],
              "description": "dry, raw, cooked, drained, … as the food's numbers are counted."
            },
            "grams": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "description": "The line's weight. All maths uses grams."
            },
            "ml": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "description": "Set for liquids."
            },
            "densityGPerMl": {
              "type": [
                "number",
                "null"
              ],
              "exclusiveMinimum": 0,
              "description": "Grams per ml, where a volume conversion is meaningful."
            },
            "aisle": {
              "type": "string",
              "minLength": 1,
              "description": "Produce, Bakery, Meat & fish, Dairy & eggs, Grains & pasta, Tins & jars, Baking, Spices & oils, Frozen, Drinks or Other. Any other name is kept and listed after Drinks, alphabetically."
            },
            "confidence": {
              "enum": [
                "high",
                "medium",
                "low"
              ],
              "description": "low shows the line as \"to check\"."
            },
            "nutrition": {
              "type": "object",
              "required": [
                "kcal",
                "protein",
                "carbs",
                "fat"
              ],
              "properties": {
                "kcal": {
                  "type": "number",
                  "minimum": 0
                },
                "protein": {
                  "type": "number",
                  "minimum": 0
                },
                "carbs": {
                  "type": "number",
                  "minimum": 0
                },
                "fat": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "description": "For the ingredient's whole amount in the recipe, not per 100 g. Protein, carbs and fat in grams."
            },
            "how": {
              "type": [
                "string",
                "null"
              ],
              "description": "How the weight was worked out, shown on review."
            },
            "assumption": {
              "type": [
                "string",
                "null"
              ],
              "description": "What was assumed, shown on review."
            },
            "userCorrected": {
              "type": "boolean",
              "description": "The cook changed the match by hand. Absent means false."
            }
          }
        }
      },
      "steps": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "position",
            "text"
          ],
          "properties": {
            "position": {
              "type": "integer",
              "minimum": 1
            },
            "title": {
              "type": [
                "string",
                "null"
              ]
            },
            "text": {
              "type": "string"
            },
            "timerSeconds": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 1,
              "description": "Offers a timer on this step."
            },
            "ingredients": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "integer",
                "minimum": 1
              },
              "description": "Positions of the ingredient lines this step uses, shown in cooking mode. [] uses none; absent or null means not known yet."
            }
          }
        }
      }
    }
  }
}
