# Extensions

## 列出扩展

`GET /extensions`

```json
{
  "tags": [
    "Extensions"
  ],
  "summary": "列出扩展",
  "description": "返回配置文件可用的扩展。在 `POST /profiles` 或 `PATCH /profiles/{id}` 的 `extensions` 字段中使用扩展 `id`。\n\n由于数据 URL 可能很大，因此省略了图标。 `POST /extensions` 包含添加的扩展程序的图标。",
  "responses": {
    "200": {
      "description": "扩展列表。",
      "content": {
        "application/json": {
          "schema": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Extension"
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```

## 添加扩展程序

`POST /extensions`

```json
{
  "tags": [
    "Extensions"
  ],
  "summary": "添加扩展程序",
  "description": "请提供 `url` 或 `path` 之一。\n\n`url` 可以是 Chrome Web Store 页面、32 位扩展 ID，或指向 `.crx` 或 `.zip` 的直接链接。启动器会自行解析商店页面并下载文件。`path` 可以是启动器所在机器上的本地 `.crx`、`.zip` 或已解压目录。\n\n名称、版本、描述和图标均来自扩展自己的 `manifest.json`。其中的 `__MSG_*__` 占位符会根据默认语言环境解析。",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/AddExtensionRequest"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "添加了扩展。响应包括 `icon`。",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Extension"
          }
        }
      }
    },
    "400": {
      "description": "既没有给出 `url` 也没有给出 `path`，链接不是扩展名，或者商店没有这样的 ID。",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```

## 删除扩展

`DELETE /extensions/{id}`

```json
{
  "tags": [
    "Extensions"
  ],
  "summary": "删除扩展",
  "description": "配置文件保存 ID，而不是副本，因此任何命名此扩展的配置文件都会在下次启动时停止加载它。他们存储的列表保持原样；重新添加扩展不会恢复绑定。",
  "parameters": [
    {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "已删除。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "deleted": {
                "type": "boolean",
                "example": true
              },
              "id": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  }
}
```
