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.PleromaEmojiFileOperation 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 create_operation do
19 tags: ["Emoji Packs"],
20 summary: "Add new file to the pack",
21 operationId: "PleromaAPI.EmojiPackController.add_file",
22 security: [%{"oAuth" => ["write"]}],
23 requestBody: request_body("Parameters", create_request(), required: true),
24 parameters: [name_param()],
26 200 => Operation.response("Files Object", "application/json", files_object()),
27 400 => Operation.response("Bad Request", "application/json", ApiError),
28 409 => Operation.response("Conflict", "application/json", ApiError)
33 defp create_request do
40 "File needs to be uploaded with the multipart request or link to remote file",
42 %Schema{type: :string, format: :binary},
43 %Schema{type: :string, format: :uri}
49 "Shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename."
54 "New emoji file name. If not specified will be taken from original filename."
60 def update_operation do
62 tags: ["Emoji Packs"],
63 summary: "Add new file to the pack",
64 operationId: "PleromaAPI.EmojiPackController.update_file",
65 security: [%{"oAuth" => ["write"]}],
66 requestBody: request_body("Parameters", update_request(), required: true),
67 parameters: [name_param()],
69 200 => Operation.response("Files Object", "application/json", files_object()),
70 400 => Operation.response("Bad Request", "application/json", ApiError),
71 409 => Operation.response("Conflict", "application/json", ApiError)
76 defp update_request do
79 required: [:shortcode, :new_shortcode, :new_filename],
83 description: "Emoji file shortcode"
85 new_shortcode: %Schema{
87 description: "New emoji file shortcode"
89 new_filename: %Schema{
91 description: "New filename for emoji file"
95 description: "With true value to overwrite existing emoji with new shortcode",
102 def delete_operation do
104 tags: ["Emoji Packs"],
105 summary: "Delete emoji file from pack",
106 operationId: "PleromaAPI.EmojiPackController.delete_file",
107 security: [%{"oAuth" => ["write"]}],
110 Operation.parameter(:shortcode, :query, :string, "File shortcode",
116 200 => Operation.response("Files Object", "application/json", files_object()),
117 400 => Operation.response("Bad Request", "application/json", ApiError)
123 Operation.parameter(:name, :path, :string, "Pack Name", example: "cofe", required: true)
129 additionalProperties: %Schema{type: :string},
130 description: "Object with emoji names as keys and filenames as values"