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
7 def open_api_operation(action) do
8 operation = String.to_existing_atom("#{action}_operation")
9 apply(__MODULE__, operation, [])
16 description: "View a hashtag",
17 security: [%{"oAuth" => ["read"]}],
18 parameters: [id_param()],
19 operationId: "TagController.show",
21 200 => Operation.response("Hashtag", "application/json", Tag),
22 404 => Operation.response("Not Found", "application/json", ApiError)
27 def follow_operation do
30 summary: "Follow a hashtag",
31 description: "Follow a hashtag",
32 security: [%{"oAuth" => ["write:follows"]}],
33 parameters: [id_param()],
34 operationId: "TagController.follow",
36 200 => Operation.response("Hashtag", "application/json", Tag),
37 404 => Operation.response("Not Found", "application/json", ApiError)
42 def unfollow_operation do
45 summary: "Unfollow a hashtag",
46 description: "Unfollow a hashtag",
47 security: [%{"oAuth" => ["write:follows"]}],
48 parameters: [id_param()],
49 operationId: "TagController.unfollow",
51 200 => Operation.response("Hashtag", "application/json", Tag),
52 404 => Operation.response("Not Found", "application/json", ApiError)
57 def show_followed_operation do
60 summary: "Followed hashtags",
61 description: "View a list of hashtags the currently authenticated user is following",
62 parameters: pagination_params(),
63 security: [%{"oAuth" => ["read:follows"]}],
64 operationId: "TagController.show_followed",
67 Operation.response("Hashtags", "application/json", %Schema{
71 403 => Operation.response("Forbidden", "application/json", ApiError),
72 404 => Operation.response("Not Found", "application/json", ApiError)
81 %Schema{type: :string},
86 def pagination_params do
88 Operation.parameter(:max_id, :query, :integer, "Return items older than this ID"),
93 "Return the oldest items newer than this ID"
98 %Schema{type: :integer, default: 20},
99 "Maximum number of items to return. Will be ignored if it's more than 40"