{
  "openapi": "3.0.3",
  "info": {
    "title": "Royal Rolls — публичный API товаров",
    "version": "1.0.0",
    "description": "Чтение опубликованных товаров без ключа. Цены в рублях. Текущая доступность для заказа и стоп-лист не передаются. Публичный API не создаёт и не изменяет заказы.",
    "contact": {
      "name": "Royal Rolls",
      "url": "https://royal-rolls.com/contacts/"
    }
  },
  "servers": [
    {
      "url": "https://royal-rolls.com/wp-json/royal/v1"
    }
  ],
  "externalDocs": {
    "description": "Документация",
    "url": "https://royal-rolls.com/api/"
  },
  "security": [],
  "paths": {
    "/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "Список опубликованных товаров",
        "description": "Результат — массив. Порядок: menu_order, затем название по возрастанию. Данные могут меняться между запросами.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            },
            "description": "Номер страницы. Значения меньше 1 приводятся к 1."
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            },
            "description": "Размер страницы: до 100. Значения больше 100 приводятся к 100, меньше или равные 0 — к 50."
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Поиск по тексту товара."
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "ID или slug категории."
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "ID или slug тега."
          },
          {
            "name": "modifiers",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Включить группы соусов и добавок. Без true массив modifiers пуст."
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              }
            },
            "headers": {
              "X-WP-Total": {
                "description": "Общее число товаров с учётом фильтров.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-WP-TotalPages": {
                "description": "Число страниц с учётом фильтров и per_page.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Ошибка запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/products/{id}": {
      "get": {
        "operationId": "getProduct",
        "summary": "Товар по ID или slug с модификаторами",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Числовой ID или slug; не SKU."
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "404": {
            "description": "Товар не найден или не опубликован.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/categories": {
      "get": {
        "operationId": "listCategories",
        "summary": "Категории, включая пустые",
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Term"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/tags": {
      "get": {
        "operationId": "listTags",
        "summary": "Теги, включая пустые",
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Term"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "required": [
          "id",
          "slug",
          "sku",
          "iiko_id",
          "name",
          "desc",
          "weight",
          "quantity",
          "price",
          "sale_price",
          "force_sale_badge",
          "thumbnail_id",
          "image_url",
          "tags",
          "categories",
          "calories",
          "proteins",
          "fats",
          "carbs",
          "calories100",
          "proteins100",
          "fats100",
          "carbs100",
          "unit",
          "has_sauces",
          "has_mods",
          "modifiers",
          "cashback_boost",
          "priority",
          "post_status",
          "publish_date",
          "permalink"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID товара на сайте."
          },
          "slug": {
            "type": "string",
            "description": "Символьный адрес товара."
          },
          "sku": {
            "type": "string",
            "description": "Артикул. Пустая строка, если не задан."
          },
          "iiko_id": {
            "type": "string",
            "description": "Идентификатор товара в iiko."
          },
          "name": {
            "type": "string",
            "description": "Название товара."
          },
          "desc": {
            "type": "string",
            "description": "Описание и состав; может содержать HTML."
          },
          "weight": {
            "type": "string",
            "description": "Вес или объём вместе с единицей измерения."
          },
          "quantity": {
            "type": "string",
            "description": "Количество в порции, если заполнено."
          },
          "price": {
            "type": "integer",
            "description": "Цена в рублях. При скидке содержит старую цену."
          },
          "sale_price": {
            "type": "integer",
            "nullable": true,
            "description": "Цена со скидкой в рублях; null при отсутствии скидки."
          },
          "force_sale_badge": {
            "type": "boolean",
            "description": "Отображение акционного бейджа; само по себе не меняет цену."
          },
          "thumbnail_id": {
            "type": "integer",
            "description": "ID изображения в WordPress."
          },
          "image_url": {
            "type": "string",
            "description": "URL оригинального изображения или пустая строка."
          },
          "tags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Tag"
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          },
          "calories": {
            "type": "string",
            "description": "Калории на порцию, ккал."
          },
          "proteins": {
            "type": "string",
            "description": "Белки на порцию, г."
          },
          "fats": {
            "type": "string",
            "description": "Жиры на порцию, г."
          },
          "carbs": {
            "type": "string",
            "description": "Углеводы на порцию, г."
          },
          "calories100": {
            "type": "string",
            "description": "Калории на 100 г, ккал."
          },
          "proteins100": {
            "type": "string",
            "description": "Белки на 100 г, г."
          },
          "fats100": {
            "type": "string",
            "description": "Жиры на 100 г, г."
          },
          "carbs100": {
            "type": "string",
            "description": "Углеводы на 100 г, г."
          },
          "unit": {
            "type": "string",
            "description": "Единица продажи."
          },
          "has_sauces": {
            "type": "boolean",
            "description": "Признак выбора соуса."
          },
          "has_mods": {
            "type": "boolean",
            "description": "Признак модификаторов. Для состава групп запросите modifiers=true."
          },
          "modifiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModifierGroup"
            }
          },
          "cashback_boost": {
            "type": "integer",
            "description": "Значение дополнительного кешбэка; 0, если не задано."
          },
          "priority": {
            "type": "integer",
            "description": "Приоритет товара."
          },
          "post_status": {
            "type": "string",
            "description": "Для публичного доступа: publish."
          },
          "publish_date": {
            "type": "string",
            "description": "Дата публикации во времени сайта: YYYY-MM-DD HH:mm:ss."
          },
          "permalink": {
            "type": "string",
            "format": "uri",
            "description": "Ссылка на страницу товара."
          }
        },
        "additionalProperties": true
      },
      "Tag": {
        "type": "object",
        "required": [
          "id",
          "name",
          "slug"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID."
          },
          "name": {
            "type": "string",
            "description": "Название."
          },
          "slug": {
            "type": "string",
            "description": "Символьное имя."
          }
        }
      },
      "Category": {
        "type": "object",
        "required": [
          "id",
          "name",
          "slug",
          "parent"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID."
          },
          "name": {
            "type": "string",
            "description": "Название."
          },
          "slug": {
            "type": "string",
            "description": "Символьное имя."
          },
          "parent": {
            "type": "integer",
            "description": "ID родительской категории; 0 у корневой."
          }
        }
      },
      "Term": {
        "type": "object",
        "required": [
          "id",
          "name",
          "slug",
          "parent",
          "count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID."
          },
          "name": {
            "type": "string",
            "description": "Название."
          },
          "slug": {
            "type": "string",
            "description": "Символьное имя."
          },
          "parent": {
            "type": "integer",
            "description": "ID родителя; 0 у корневой записи."
          },
          "count": {
            "type": "integer",
            "description": "Число опубликованных товаров непосредственно в этой категории или с этим тегом."
          }
        }
      },
      "ModifierGroup": {
        "type": "object",
        "required": [
          "name",
          "iiko_id",
          "minAmount",
          "maxAmount",
          "required",
          "items"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Название группы."
          },
          "iiko_id": {
            "type": "string",
            "description": "ID группы в iiko."
          },
          "minAmount": {
            "type": "integer",
            "description": "Минимальное количество."
          },
          "maxAmount": {
            "type": "integer",
            "description": "Максимальное количество."
          },
          "required": {
            "type": "boolean",
            "description": "Обязательность выбора."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModifierItem"
            }
          }
        }
      },
      "ModifierItem": {
        "type": "object",
        "required": [
          "name",
          "price",
          "iiko_item_id",
          "iiko_group_id"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Название добавки."
          },
          "price": {
            "type": "integer",
            "description": "Цена добавки в рублях."
          },
          "iiko_item_id": {
            "type": "string",
            "description": "ID добавки в iiko."
          },
          "iiko_group_id": {
            "type": "string",
            "description": "ID группы в iiko."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message",
          "data"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Код ошибки."
          },
          "message": {
            "type": "string",
            "description": "Описание ошибки."
          },
          "data": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer",
                "description": "HTTP-статус."
              }
            },
            "additionalProperties": true
          }
        }
      }
    }
  }
}
