{
  "openapi": "3.0.1",
  "info": {
    "title": "Документация по SelSup API",
    "description": "API SelSup — программный интерфейс для работы с сервисом SelSup. Даёт возможность работать со всеми функциями SelSup из вашей системы. Для использования API добавьте новый токен на странице:https://selsup.ru/application/integration/api. Добавленный токен необходимо передавать во всех запросах к API SelSup, в заголовке Authorization.",
    "contact": {
      "name": "Support Team",
      "email": "admin@selsup.ru"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://selsup.ru/dogovor-offerta/"
    },
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.selsup.ru/",
      "description": "Production server"
    }
  ],
  "tags": [
    {
      "name": "Ключевые слова",
      "description": "Методы для работы с ключевыми словами для товаров для формирования описания"
    }
  ],
  "paths": {
    "/api/keyword/group/{groupId}": {
      "get": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Получить список всех слов из группы",
        "description": "Возвращает список всех слов из указанной группе",
        "operationId": "getKeywordFromGroup",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "description": "Идентификатор группы",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/KeywordGroup"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Редактировать группу слов",
        "description": "Удаление или добавления слов в группе",
        "operationId": "editKeywordGroupById",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "newName",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/KeywordGroup"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Удаление группы ключевых слов",
        "description": "Удаляет группу ключевых слов и её связи",
        "operationId": "deleteKeywordGroup",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "description": "Группа которую надо удалить",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/KeywordGroup"
                }
              }
            }
          }
        }
      }
    },
    "/api/keyword/add": {
      "put": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Добавляет группу к сущности",
        "description": "Добавляет группу слов к одной или нескольким сущностям",
        "operationId": "addKeywordGroup",
        "parameters": [
          {
            "name": "productId",
            "in": "query",
            "description": "Идентификатор товар к которому добавляется группы",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "productViewId",
            "in": "query",
            "description": "Идентификатор цвета к которому добавляется группы",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "modelId",
            "in": "query",
            "description": "Идентификатор модели к которому добавляется группы",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "description": "Группа которую надо добавить",
                "items": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/keyword/group": {
      "get": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Список всех групп слов и слов клиента",
        "description": "Возвращает список групп ключевых слов и их содержимое клиента",
        "operationId": "getKeywordGroup",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KeywordGroup"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Создает новую группу слов",
        "description": "Создает новую пустую группу слов в бд",
        "operationId": "createKeywordGroup",
        "parameters": [
          {
            "name": "groupName",
            "in": "query",
            "description": "Название группы слов",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/KeywordGroup"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Удаление групп ключевых слов",
        "description": "Удаляет указанные группы ключевых слов и их связи",
        "operationId": "deleteKeywordGroups",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "description": "Группы которые надо удалить",
                "items": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/keyword/group/merge": {
      "post": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Соединение групп ключевых слов",
        "description": "Объединяет указанные группы ключевых слов и обновляет их связи",
        "operationId": "mergeKeywordGroups",
        "parameters": [
          {
            "name": "newGroupName",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/KeywordGroup"
                }
              }
            }
          }
        }
      }
    },
    "/api/keyword/{modelId}": {
      "get": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Получить список всех слов и групп сущности",
        "description": "Возвращает всех слов и список всех групп слов для указанной карточки",
        "operationId": "getKeywordForEntity",
        "parameters": [
          {
            "name": "modelId",
            "in": "path",
            "description": "Идентификатор модели для которой получаем список",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/KeywordAndGroup"
                }
              }
            }
          }
        }
      }
    },
    "/api/keyword/group/find": {
      "get": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Найти группу ключевых слов",
        "description": "Возвращает список групп ключевых слов найденных по указным словам",
        "operationId": "findKeywordGroup",
        "parameters": [
          {
            "name": "word",
            "in": "query",
            "description": "Слово для поиска",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KeywordGroup"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/keyword/model/{modelId}": {
      "delete": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Удаление связи группы слов и сущности",
        "description": "Удаляет связь между группой слов и сущностью",
        "operationId": "deleteKeywordGroupFromEntity",
        "parameters": [
          {
            "name": "modelId",
            "in": "path",
            "description": "Идентификатор модели у которой удаляются группы",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "description": "Группы слов которое надо удалить",
                "items": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/keyword/group/{groupId}/keywords": {
      "delete": {
        "tags": [
          "Ключевые слова"
        ],
        "summary": "Удаление ключевых слов из группы",
        "description": "Удаляет указанные ключевые слова из группы клиента",
        "operationId": "deleteKeywordFromGroup",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "description": "Идентификатор группы из которой удаляются слова",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "description": "Ключевые слова которые надо удалить",
                "items": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Keyword": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string",
            "description": "Название ключевого слово"
          },
          "usingQuantity": {
            "type": "integer",
            "format": "int32"
          }
        },
        "description": "Ключевое слово"
      },
      "KeywordGroup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string",
            "description": "Название группы ключевых слова"
          },
          "keywords": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Keyword"
            }
          }
        },
        "description": "Название группы ключевых слов"
      },
      "KeywordAndGroup": {
        "type": "object",
        "properties": {
          "keyword": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Keyword"
            }
          },
          "group": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KeywordGroup"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "name": "Authorization",
        "in": "header"
      }
    }
  }
}