a117fe460bc955d127ff5ec204167e0a2fd095f0
[akkoma] / lib / pleroma / web / api_spec / operations / custom_emoji_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.CustomEmojiOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.CustomEmoji
9
10 def open_api_operation(action) do
11 operation = String.to_existing_atom("#{action}_operation")
12 apply(__MODULE__, operation, [])
13 end
14
15 def index_operation do
16 %Operation{
17 tags: ["custom_emojis"],
18 summary: "List custom custom emojis",
19 description: "Returns custom emojis that are available on the server.",
20 operationId: "CustomEmojiController.index",
21 responses: %{
22 200 => Operation.response("Custom Emojis", "application/json", custom_emojis_resposnse())
23 }
24 }
25 end
26
27 defp custom_emojis_resposnse do
28 %Schema{
29 title: "CustomEmojisResponse",
30 description: "Response schema for custom emojis",
31 type: :array,
32 items: CustomEmoji,
33 example: [
34 %{
35 "category" => "Fun",
36 "shortcode" => "blank",
37 "static_url" => "https://lain.com/emoji/blank.png",
38 "tags" => ["Fun"],
39 "url" => "https://lain.com/emoji/blank.png",
40 "visible_in_picker" => false
41 },
42 %{
43 "category" => "Gif,Fun",
44 "shortcode" => "firefox",
45 "static_url" => "https://lain.com/emoji/Firefox.gif",
46 "tags" => ["Gif", "Fun"],
47 "url" => "https://lain.com/emoji/Firefox.gif",
48 "visible_in_picker" => true
49 },
50 %{
51 "category" => "pack:mixed",
52 "shortcode" => "sadcat",
53 "static_url" => "https://lain.com/emoji/mixed/sadcat.png",
54 "tags" => ["pack:mixed"],
55 "url" => "https://lain.com/emoji/mixed/sadcat.png",
56 "visible_in_picker" => true
57 }
58 ]
59 }
60 end
61 end