{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ymove-app/json-schema/ymove-app-meal-plan-schema.json",
  "title": "MealPlan",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ymove-app-openapi.json#/components/schemas/MealPlan",
  "type": "object",
  "properties": {
    "calories": {
      "type": "integer",
      "description": "Daily calorie target"
    },
    "diet": {
      "type": "string"
    },
    "macroSplit": {
      "type": "string"
    },
    "mealsPerDay": {
      "type": "integer",
      "description": "Number of meals per day"
    },
    "daysCount": {
      "type": "integer",
      "description": "Number of days in this plan (1-7)"
    },
    "averageDailyTotals": {
      "type": "object",
      "description": "Average per-day macros across all days in the plan.",
      "properties": {
        "calories": {
          "type": "number"
        },
        "protein": {
          "type": "number"
        },
        "carbs": {
          "type": "number"
        },
        "fat": {
          "type": "number"
        }
      }
    },
    "days": {
      "type": "array",
      "description": "Per-day breakdown of the plan. Always populated, even for daysCount=1.",
      "items": {
        "type": "object",
        "properties": {
          "dayIndex": {
            "type": "integer",
            "description": "1-based day number"
          },
          "totals": {
            "type": "object",
            "properties": {
              "calories": {
                "type": "number"
              },
              "protein": {
                "type": "number"
              },
              "carbs": {
                "type": "number"
              },
              "fat": {
                "type": "number"
              }
            }
          },
          "meals": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/MealPlanMeal"
            }
          }
        }
      }
    },
    "totals": {
      "type": "object",
      "description": "Backward-compatible alias for days[0].totals (day 1 only). For multi-day plans use averageDailyTotals or per-day totals in days[].",
      "properties": {
        "calories": {
          "type": "number"
        },
        "protein": {
          "type": "number"
        },
        "carbs": {
          "type": "number"
        },
        "fat": {
          "type": "number"
        }
      }
    },
    "meals": {
      "type": "array",
      "description": "Backward-compatible alias for days[0].meals (day 1 only).",
      "items": {
        "$ref": "#/$defs/MealPlanMeal"
      }
    }
  },
  "$defs": {
    "MealPlanMeal": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "breakfast | lunch | dinner | snack"
        },
        "name": {
          "type": "string",
          "description": "Recipe title (same as recipe.title)"
        },
        "recipeId": {
          "type": "string",
          "description": "Recipe.id - use to look up the full recipe or fetch its image"
        },
        "recipeSlug": {
          "type": "string"
        },
        "imageUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "portionMultiplier": {
          "type": "number",
          "description": "Multiplier applied to the recipe (0.5-2.0). Macros + ingredient quantities are already scaled."
        },
        "calories": {
          "type": "number",
          "description": "Already scaled by portionMultiplier"
        },
        "protein": {
          "type": "number"
        },
        "carbs": {
          "type": "number"
        },
        "fat": {
          "type": "number"
        },
        "recipe": {
          "type": "object",
          "description": "Full recipe metadata so clients can render title + prep time + servings + image without a second API call.",
          "properties": {
            "id": {
              "type": "string"
            },
            "title": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            },
            "description": {
              "type": [
                "string",
                "null"
              ]
            },
            "mealType": {
              "type": "string"
            },
            "cuisineType": {
              "type": [
                "string",
                "null"
              ]
            },
            "difficulty": {
              "type": [
                "string",
                "null"
              ]
            },
            "prepTimeMin": {
              "type": "integer"
            },
            "cookTimeMin": {
              "type": "integer"
            },
            "servings": {
              "type": "integer"
            },
            "dietTags": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "instructions": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Ordered cooking steps, so clients can render the full recipe without a second call."
            },
            "imageUrl": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "foods": {
          "type": "array",
          "description": "Recipe ingredients with quantities + macros already scaled by portionMultiplier.",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "portion": {
                "type": "string",
                "description": "e.g. \"200 g\", \"1.5 tbsp\""
              },
              "calories": {
                "type": "number"
              },
              "protein": {
                "type": "number"
              },
              "carbs": {
                "type": "number"
              },
              "fat": {
                "type": "number"
              }
            }
          }
        }
      }
    }
  }
}