1 defmodule Pleroma.Web.ApiSpec.FrontendSettingsOperation do
2 alias OpenApiSpex.Operation
3 alias OpenApiSpex.Schema
4 import Pleroma.Web.ApiSpec.Helpers
6 @spec open_api_operation(atom) :: Operation.t()
7 def open_api_operation(action) do
8 operation = String.to_existing_atom("#{action}_operation")
9 apply(__MODULE__, operation, [])
12 @spec list_profiles_operation() :: Operation.t()
13 def list_profiles_operation() do
15 tags: ["Retrieve frontend setting profiles"],
16 summary: "Frontend Settings Profiles",
17 description: "List frontend setting profiles",
18 operationId: "AkkomaAPI.FrontendSettingsController.list_profiles",
19 parameters: [frontend_name_param()],
20 security: [%{"oAuth" => ["read:accounts"]}],
23 Operation.response("Profiles", "application/json", %Schema{
28 name: %Schema{type: :string},
29 version: %Schema{type: :integer}
37 @spec get_profile_operation() :: Operation.t()
38 def get_profile_operation() do
40 tags: ["Retrieve frontend setting profile"],
41 summary: "Frontend Settings Profile",
42 description: "Get frontend setting profile",
43 operationId: "AkkomaAPI.FrontendSettingsController.get_profile",
44 security: [%{"oAuth" => ["read:accounts"]}],
45 parameters: [frontend_name_param(), profile_name_param()],
48 Operation.response("Profile", "application/json", %Schema{
51 "version" => %Schema{type: :integer},
52 "settings" => %Schema{type: :object, additionalProperties: true}
55 404 => Operation.response("Not Found", "application/json", %Schema{type: :object})
60 @spec delete_profile_operation() :: Operation.t()
61 def delete_profile_operation() do
63 tags: ["Delete frontend setting profile"],
64 summary: "Delete frontend Settings Profile",
65 description: "Delete frontend setting profile",
66 operationId: "AkkomaAPI.FrontendSettingsController.delete_profile",
67 security: [%{"oAuth" => ["write:accounts"]}],
68 parameters: [frontend_name_param(), profile_name_param()],
70 200 => Operation.response("Empty", "application/json", %Schema{type: :object}),
71 404 => Operation.response("Not Found", "application/json", %Schema{type: :object})
76 @spec update_profile_operation() :: Operation.t()
77 def update_profile_operation() do
79 tags: ["Update frontend setting profile"],
80 summary: "Frontend Settings Profile",
81 description: "Update frontend setting profile",
82 operationId: "AkkomaAPI.FrontendSettingsController.update_profile_operation",
83 security: [%{"oAuth" => ["write:accounts"]}],
84 parameters: [frontend_name_param(), profile_name_param()],
85 requestBody: profile_body_param(),
87 200 => Operation.response("Settings", "application/json", %Schema{type: :object}),
88 422 => Operation.response("Invalid", "application/json", %Schema{type: :object})
93 def frontend_name_param do
94 Operation.parameter(:frontend_name, :path, :string, "Frontend name",
95 example: "pleroma-fe",
100 def profile_name_param do
101 Operation.parameter(:profile_name, :path, :string, "Profile name",
107 def profile_body_param do
111 title: "Frontend Setting Profile",
113 required: [:version, :settings],
117 description: "Version of the profile, must increment by 1 each time",
122 description: "Settings of the profile",