1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.Admin.ConfigOperation 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, [])
19 tags: ["Admin", "Config"],
20 summary: "Get list of merged default settings with saved in database",
21 operationId: "AdminAPI.ConfigController.show",
26 %Schema{type: :boolean, default: false},
27 "Get only saved in database settings"
30 security: [%{"oAuth" => ["read"]}],
32 200 => Operation.response("Config", "application/json", config_response()),
33 400 => Operation.response("Bad Request", "application/json", ApiError)
38 def update_operation do
40 tags: ["Admin", "Config"],
41 summary: "Update config settings",
42 operationId: "AdminAPI.ConfigController.update",
43 security: [%{"oAuth" => ["write"]}],
45 request_body("Parameters", %Schema{
53 group: %Schema{type: :string},
54 key: %Schema{type: :string},
56 delete: %Schema{type: :boolean},
57 subkeys: %Schema{type: :array, items: %Schema{type: :string}}
64 200 => Operation.response("Config", "application/json", config_response()),
65 400 => Operation.response("Bad Request", "application/json", ApiError)
70 def descriptions_operation do
72 tags: ["Admin", "Config"],
73 summary: "Get JSON with config descriptions.",
74 operationId: "AdminAPI.ConfigController.descriptions",
75 security: [%{"oAuth" => ["read"]}],
78 Operation.response("Config Descriptions", "application/json", %Schema{
83 group: %Schema{type: :string},
84 key: %Schema{type: :string},
85 type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
86 description: %Schema{type: :string},
92 key: %Schema{type: :string},
93 type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
94 description: %Schema{type: :string},
95 suggestions: %Schema{type: :array}
102 400 => Operation.response("Bad Request", "application/json", ApiError)
110 %Schema{type: :array},
111 %Schema{type: :object},
112 %Schema{type: :string},
113 %Schema{type: :integer},
114 %Schema{type: :boolean}
119 defp config_response do
128 group: %Schema{type: :string},
129 key: %Schema{type: :string},
134 need_reboot: %Schema{
137 "If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect"