Remerge of hashtag following (#341)
[akkoma] / lib / pleroma / web / api_spec / operations / tag_operation.ex
1 defmodule Pleroma.Web.ApiSpec.TagOperation do
2 alias OpenApiSpex.Operation
3 alias OpenApiSpex.Schema
4 alias Pleroma.Web.ApiSpec.Schemas.ApiError
5 alias Pleroma.Web.ApiSpec.Schemas.Tag
6
7 def open_api_operation(action) do
8 operation = String.to_existing_atom("#{action}_operation")
9 apply(__MODULE__, operation, [])
10 end
11
12 def show_operation do
13 %Operation{
14 tags: ["Tags"],
15 summary: "Hashtag",
16 description: "View a hashtag",
17 security: [%{"oAuth" => ["read"]}],
18 parameters: [id_param()],
19 operationId: "TagController.show",
20 responses: %{
21 200 => Operation.response("Hashtag", "application/json", Tag),
22 404 => Operation.response("Not Found", "application/json", ApiError)
23 }
24 }
25 end
26
27 def follow_operation do
28 %Operation{
29 tags: ["Tags"],
30 summary: "Follow a hashtag",
31 description: "Follow a hashtag",
32 security: [%{"oAuth" => ["write:follows"]}],
33 parameters: [id_param()],
34 operationId: "TagController.follow",
35 responses: %{
36 200 => Operation.response("Hashtag", "application/json", Tag),
37 404 => Operation.response("Not Found", "application/json", ApiError)
38 }
39 }
40 end
41
42 def unfollow_operation do
43 %Operation{
44 tags: ["Tags"],
45 summary: "Unfollow a hashtag",
46 description: "Unfollow a hashtag",
47 security: [%{"oAuth" => ["write:follow"]}],
48 parameters: [id_param()],
49 operationId: "TagController.unfollow",
50 responses: %{
51 200 => Operation.response("Hashtag", "application/json", Tag),
52 404 => Operation.response("Not Found", "application/json", ApiError)
53 }
54 }
55 end
56
57 defp id_param do
58 Operation.parameter(
59 :id,
60 :path,
61 %Schema{type: :string},
62 "Name of the hashtag"
63 )
64 end
65 end