1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.Admin.FrontendOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
10 import Pleroma.Web.ApiSpec.Helpers
12 def open_api_operation(action) do
13 operation = String.to_existing_atom("#{action}_operation")
14 apply(__MODULE__, operation, [])
17 def index_operation do
19 tags: ["Frontend managment"],
20 summary: "Retrieve a list of available frontends",
21 operationId: "AdminAPI.FrontendController.index",
22 security: [%{"oAuth" => ["admin:read"]}],
24 200 => Operation.response("Response", "application/json", list_of_frontends()),
25 403 => Operation.response("Forbidden", "application/json", ApiError)
30 def install_operation do
32 tags: ["Frontend managment"],
33 summary: "Install a frontend",
34 operationId: "AdminAPI.FrontendController.install",
35 security: [%{"oAuth" => ["admin:read"]}],
36 requestBody: request_body("Parameters", install_request(), required: true),
38 200 => Operation.response("Response", "application/json", list_of_frontends()),
39 403 => Operation.response("Forbidden", "application/json", ApiError),
40 400 => Operation.response("Error", "application/json", ApiError)
45 defp list_of_frontends do
51 name: %Schema{type: :string},
52 git: %Schema{type: :string, format: :uri, nullable: true},
53 build_url: %Schema{type: :string, format: :uri, nullable: true},
54 ref: %Schema{type: :string},
55 installed: %Schema{type: :boolean}
61 defp install_request do
63 title: "FrontendInstallRequest",