{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/layout-link/json-schema/layout-link-menu-result-schema.json",
  "title": "MenuResult",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/layout-link-openapi.json#/components/schemas/MenuResult",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "menu"
        },
        "restaurant": {
          "$ref": "#/$defs/MenuRestaurant"
        },
        "assumedNearest": {
          "description": "True when the name matched several branches and Layout read the nearest one. Tell the person which.",
          "type": "boolean"
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/MenuItem"
          }
        },
        "confidence": {
          "description": "`partial`: this may not be the whole menu.",
          "type": "string",
          "enum": [
            "high",
            "partial"
          ]
        },
        "pricesUnavailable": {
          "description": "The site gave no prices when it was read. Never fill one in.",
          "type": "boolean"
        },
        "scope": {
          "description": "`chain`: this location's own menu is not read yet or could not be read, so these are the items at least half of the restaurant's read locations list. Never priced (`pricesUnavailable` is true, since prices vary by location), and this location may not carry every item. Absent: this location's own menu.",
          "type": "string",
          "const": "chain"
        },
        "readAt": {
          "description": "When Layout read this whole menu from the site, for a menu served from that read rather than read just now. Absent: read just now.",
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-]\\d{2}:\\d{2})))$"
        }
      },
      "required": [
        "status",
        "restaurant",
        "assumedNearest",
        "items",
        "confidence",
        "pricesUnavailable"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "categories"
        },
        "restaurant": {
          "$ref": "#/$defs/MenuRestaurant"
        },
        "assumedNearest": {
          "description": "True when the name matched several branches and Layout read the nearest one. Tell the person which.",
          "type": "boolean"
        },
        "categories": {
          "description": "Read one by sending it back as `category`.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "status",
        "restaurant",
        "assumedNearest",
        "categories"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "reading"
        },
        "menuId": {
          "$ref": "#/$defs/MenuId"
        },
        "restaurant": {
          "$ref": "#/$defs/MenuRestaurant"
        },
        "assumedNearest": {
          "description": "True when the name matched several branches and Layout read the nearest one. Tell the person which.",
          "type": "boolean"
        },
        "retryAfterSec": {
          "description": "When to poll GET /menus/{menuId}.",
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "status",
        "menuId",
        "restaurant",
        "assumedNearest",
        "retryAfterSec"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "knowledge"
        },
        "restaurant": {
          "$ref": "#/$defs/MenuRestaurant"
        },
        "knowledge": {
          "description": "General knowledge, not the live menu. Prices are not current.",
          "type": "string"
        },
        "live": {
          "type": "boolean",
          "const": false
        }
      },
      "required": [
        "status",
        "knowledge",
        "live"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "unreadable"
        },
        "restaurant": {
          "$ref": "#/$defs/MenuRestaurant"
        }
      },
      "required": [
        "status"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "not_found"
        }
      },
      "required": [
        "status"
      ]
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "needs_location"
        },
        "candidates": {
          "description": "Send one back as `placeId`. Empty: send `near` or coordinates.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "placeId": {
                "$ref": "#/$defs/PlaceId"
              },
              "name": {
                "type": "string"
              },
              "address": {
                "type": "string"
              },
              "distanceMi": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "placeId",
              "name",
              "address",
              "distanceMi"
            ]
          }
        }
      },
      "required": [
        "status",
        "candidates"
      ]
    }
  ],
  "$defs": {
    "ItemImage": {
      "type": "object",
      "properties": {
        "url": {
          "description": "A JPEG, up to 1000px on its long side, served from Layout's CDN. Show this URL; do not copy the file.",
          "type": "string"
        },
        "webpUrl": {
          "description": "The same photo as WebP, smaller.",
          "type": "string"
        },
        "width": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "height": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "source": {
          "description": "`menu`: from the restaurant's own menu. `product_page`: from its own page for the item.",
          "type": "string",
          "enum": [
            "menu",
            "product_page"
          ]
        },
        "checkedAt": {
          "description": "When Layout last checked the photo against the restaurant's site (ISO 8601).",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "url",
        "webpUrl",
        "width",
        "height",
        "source",
        "checkedAt"
      ]
    },
    "MenuId": {
      "type": "string",
      "pattern": "^mnu_[A-Za-z0-9_-]{16,4092}$"
    },
    "MenuItem": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "image": {
          "description": "The restaurant's own photo of the item, when Layout already holds one. Absent: none held yet; POST /images/items finds one.",
          "$ref": "#/$defs/ItemImage"
        },
        "priceMinor": {
          "description": "Minor units. 429 is $4.29. Absent when the site did not give one.",
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "description": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "optionGroups": {
          "description": "Absent: not read. Empty: read, and the item needs no choices.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/MenuOptionGroup"
          }
        },
        "soldOut": {
          "description": "The restaurant marked it sold out when the menu was read. A cart with it is refused.",
          "type": "boolean",
          "const": true
        }
      },
      "required": [
        "name"
      ]
    },
    "MenuOptionGroup": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "moreOptions": {
          "description": "Options beyond the ones listed.",
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "defaults": {
          "description": "The options the item comes with, written as in `options`, when the restaurant preselects any. A group with defaults is already chosen: change it only when the person asks. Absent: none preselected.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "name",
        "required",
        "options"
      ]
    },
    "MenuRestaurant": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "address": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "name",
        "address"
      ]
    },
    "PlaceId": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{1,255}$"
    }
  }
}