1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.PleromaSettingsOperation do
alias OpenApiSpex.Operation
alias OpenApiSpex.Schema
import Pleroma.Web.ApiSpec.Helpers
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
apply(__MODULE__, operation, [])
end
def show_operation do
%Operation{
tags: ["Settings"],
summary: "Get settings for an application",
description: "Get synchronized settings for an application",
operationId: "SettingsController.show",
parameters: [app_name_param()],
security: [%{"oAuth" => ["read:accounts"]}],
responses: %{
200 => Operation.response("object", "application/json", object())
}
}
end
def update_operation do
%Operation{
tags: ["Settings"],
summary: "Update settings for an application",
description: "Update synchronized settings for an application",
operationId: "SettingsController.update",
parameters: [app_name_param()],
security: [%{"oAuth" => ["write:accounts"]}],
requestBody: request_body("Parameters", update_request(), required: true),
responses: %{
200 => Operation.response("object", "application/json", object())
}
}
end
def app_name_param do
Operation.parameter(:app, :path, %Schema{type: :string}, "Application name",
example: "pleroma-fe",
required: true
)
end
def object do
%Schema{
title: "Settings object",
description: "The object that contains settings for the application.",
type: :object
}
end
def update_request do
%Schema{
title: "SettingsUpdateRequest",
type: :object,
description:
"The settings object to be merged with the current settings. To remove a field, set it to null.",
example: %{
"config1" => true,
"config2_to_unset" => nil
}
}
end
end
|