{
  "openapi": "3.1.0",
  "info": {
    "title": "Спорттовары — API для ИИ-агентов (демо)",
    "version": "1.0.0",
    "description": "Поиск товаров, наличие в магазине и создание брони. Демо-данные."
  },
  "servers": [
    {
      "url": "https://sportmarket.slscustom.ru"
    }
  ],
  "paths": {
    "/api/v1/products/": {
      "get": {
        "summary": "Поиск товаров",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "in_stock",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Список товаров"
          }
        }
      }
    },
    "/api/v1/products/{slug}/": {
      "get": {
        "summary": "Карточка товара",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Товар"
          },
          "404": {
            "description": "Не найден"
          }
        }
      }
    },
    "/api/v1/stores/": {
      "get": {
        "summary": "Магазины и самовывоз",
        "responses": {
          "200": {
            "description": "Список магазинов"
          }
        }
      }
    },
    "/api/v1/reservations/": {
      "post": {
        "summary": "Создать бронь",
        "description": "Нужно явное согласие пользователя (consent: true).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "phone",
                  "items",
                  "consent"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "consent": {
                    "type": "boolean"
                  },
                  "payment": {
                    "type": "string",
                    "enum": [
                      "cash",
                      "online",
                      "invoice"
                    ]
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "product_id",
                        "qty"
                      ],
                      "properties": {
                        "product_id": {
                          "type": "integer"
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 10
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Бронь создана, вернётся номер и код выдачи"
          },
          "422": {
            "description": "Ошибка валидации"
          }
        }
      }
    },
    "/api/v1/orders/{number}/": {
      "get": {
        "summary": "Статус брони",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Статус"
          },
          "404": {
            "description": "Не найдено"
          }
        }
      }
    }
  }
}