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
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
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
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
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 available_frontends_operation() do
96 summary: "Frontend Settings Profiles",
97 description: "List frontend setting profiles",
98 operationId: "AkkomaAPI.FrontendSettingsController.available_frontends",
101 Operation.response("Frontends", "application/json", %Schema{
111 def update_preferred_frontend_operation() do
114 summary: "Frontend Settings Profiles",
115 description: "List frontend setting profiles",
116 operationId: "AkkomaAPI.FrontendSettingsController.available_frontends",
122 required: [:frontend_name],
124 frontend_name: %Schema{
126 description: "Frontend name"
134 Operation.response("Frontends", "application/json", %Schema{
144 def frontend_name_param do
145 Operation.parameter(:frontend_name, :path, :string, "Frontend name",
146 example: "pleroma-fe",
151 def profile_name_param do
152 Operation.parameter(:profile_name, :path, :string, "Profile name",
158 def profile_body_param do
162 title: "Frontend Setting Profile",
164 required: [:version, :settings],
168 description: "Version of the profile, must increment by 1 each time",
173 description: "Settings of the profile",