summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/api_spec/operations/directory_operation.ex
blob: 9be965feb1cce9e1be7b22b0cc89891a931380fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.ApiSpec.DirectoryOperation do
  alias OpenApiSpex.Operation
  alias Pleroma.Web.ApiSpec.AccountOperation
  alias Pleroma.Web.ApiSpec.Schemas.ApiError
  alias Pleroma.Web.ApiSpec.Schemas.BooleanLike

  import Pleroma.Web.ApiSpec.Helpers

  def open_api_operation(action) do
    operation = String.to_existing_atom("#{action}_operation")
    apply(__MODULE__, operation, [])
  end

  def index_operation do
    %Operation{
      tags: ["Directory"],
      summary: "Profile directory",
      operationId: "DirectoryController.index",
      parameters:
        [
          Operation.parameter(
            :order,
            :query,
            :string,
            "Order by recent activity or account creation",
            required: nil
          ),
          Operation.parameter(:local, :query, BooleanLike, "Include local users only")
        ] ++ pagination_params(),
      responses: %{
        200 =>
          Operation.response("Accounts", "application/json", AccountOperation.array_of_accounts()),
        404 => Operation.response("Not Found", "application/json", ApiError)
      }
    }
  end
end