{
  "openapi": "3.0.3",
  "info": {
    "title": "api/filestorage",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/avatars/": {
      "post": {
        "summary": "Загружает логотип фирмы или аватарку контакта",
        "parameters": [
          {
            "name": "account",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Если этот параметр есть в строке запроса, то загружается\nлоготип фирмы\n"
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "img": {
                    "type": "string",
                    "format": "binary",
                    "description": "Тело файла"
                  }
                },
                "required": [
                  "img"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AvatarUploadInfo"
          },
          "401": {
            "description": "Ошибка авторизации"
          }
        },
        "tags": [
          "avatars"
        ]
      },
      "delete": {
        "summary": "Удаляет логотип фирмы или аватарку контакта",
        "parameters": [
          {
            "name": "account",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Если этот параметр есть в строке запроса, то удаляется\nлоготип фирмы\n"
          }
        ],
        "responses": {
          "200": {
            "description": "Логотип/аватарка удалена"
          },
          "401": {
            "description": "Ошибка авторизации"
          }
        },
        "tags": [
          "avatars"
        ]
      }
    },
    "/avatars/logo": {
      "post": {
        "summary": "Загружает логотип фирмы",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "img": {
                    "type": "string",
                    "format": "binary",
                    "description": "Тело файла"
                  }
                },
                "required": [
                  "img"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/AvatarUploadInfo"
          },
          "401": {
            "description": "Ошибка авторизации"
          }
        },
        "tags": [
          "avatars"
        ]
      }
    },
    "/v1.0/filestorage/files/": {
      "post": {
        "summary": "Загрузить файл в хранилище",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "firms": {
                    "type": "string",
                    "description": "Список фирм, имеющих доступ к этому документу"
                  },
                  "rawBody": {
                    "type": "string",
                    "format": "binary",
                    "description": "Тело файла"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Информация о файле - id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "description": "Идентификатор успешности запроса"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Идентификатор файла"
                        },
                        "fileName": {
                          "type": "string",
                          "description": "Имя файла"
                        },
                        "size": {
                          "type": "integer",
                          "description": "Размер файла в байтах"
                        },
                        "mimetype": {
                          "type": "string",
                          "description": "Тип файла"
                        },
                        "link": {
                          "type": "string",
                          "description": "Ссылка на файл для скачивания"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Отсутствует файл в поле rawBody, или Отправлен пустой файл"
          },
          "401": {
            "description": "Ошибка авторизации"
          }
        },
        "tags": [
          "files"
        ]
      }
    },
    "/v1.0/filestorage/files/multiple": {
      "post": {
        "summary": "Загрузить несколько файлов в хранилище",
        "requestBody": {
          "description": "Загружаемые файлы",
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "firms": {
                    "type": "string",
                    "description": "Список фирм, имеющих доступ к этому документу"
                  },
                  "rawBody": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary",
                      "description": "Список из тел файла"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Список с информацией о созданных файлах и ошибках",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/file_success"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Отсутствует или пустое поле rawBody"
          },
          "401": {
            "description": "Ошибка авторизации"
          }
        },
        "tags": [
          "files"
        ]
      },
      "delete": {
        "summary": "Удалить несколько файлов из хранилища",
        "requestBody": {
          "description": "Идентификаторы удаляемых файлов",
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string",
                  "description": "Идентификатор файла"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Список с информацией о созданных файлах и ошибках",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "ok": {
                        "type": "boolean"
                      },
                      "id": {
                        "type": "string",
                        "title": "Идентификатор файла"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Отсутствует или пустое поле rawBody"
          },
          "401": {
            "description": "Ошибка авторизации"
          }
        },
        "tags": [
          "files"
        ]
      }
    },
    "/v1.0/filestorage/files/{file_id}/": {
      "delete": {
        "summary": "Удалить файл",
        "parameters": [
          {
            "$ref": "#/components/parameters/FileId"
          }
        ],
        "responses": {
          "200": {
            "description": "Подверждение об удалении файла"
          },
          "400": {
            "description": "Файл не найден"
          }
        },
        "tags": [
          "files"
        ]
      },
      "get": {
        "summary": "Получить файл по его ID",
        "parameters": [
          {
            "$ref": "#/components/parameters/FileId"
          }
        ],
        "responses": {
          "200": {
            "description": "Содержимое файла"
          },
          "400": {
            "description": "Файл не найден"
          }
        },
        "tags": [
          "files"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "file_success": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "result": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "title": "Идентификатор файла"
              },
              "fileName": {
                "type": "string",
                "title": "Имя файла"
              },
              "size": {
                "type": "integer",
                "title": "Размер файла в байтах"
              },
              "mimetype": {
                "type": "string",
                "title": "Тип файла"
              },
              "link": {
                "type": "string",
                "title": "Ссылка на файл для скачивания"
              }
            }
          }
        }
      }
    },
    "parameters": {
      "FileId": {
        "name": "file_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "description": "Идентификатор файла"
      }
    },
    "responses": {
      "AvatarUploadInfo": {
        "description": "Информация о загруженной аватарке/логотипе",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "ok": {
                  "type": "boolean",
                  "description": "Идентификатор успешности запроса"
                },
                "url": {
                  "type": "string",
                  "description": "Ссылка на сохраненный аватар"
                },
                "name": {
                  "type": "string",
                  "description": "Имя сохраненной аватарки"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}