MastoAPI: Profile directory
[akkoma] / lib / pleroma / web / api_spec / operations / directory_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.DirectoryOperation do
6 alias OpenApiSpex.Operation
7 alias Pleroma.Web.ApiSpec.AccountOperation
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9 alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
10
11 import Pleroma.Web.ApiSpec.Helpers
12
13 def open_api_operation(action) do
14 operation = String.to_existing_atom("#{action}_operation")
15 apply(__MODULE__, operation, [])
16 end
17
18 def index_operation do
19 %Operation{
20 tags: ["Directory"],
21 summary: "Profile directory",
22 operationId: "DirectoryController.index",
23 parameters:
24 [
25 Operation.parameter(
26 :order,
27 :query,
28 :string,
29 "Order by recent activity or account creation",
30 required: nil
31 ),
32 Operation.parameter(:local, :query, BooleanLike, "Include local users only")
33 ] ++ pagination_params(),
34 responses: %{
35 200 =>
36 Operation.response("Accounts", "application/json", AccountOperation.array_of_accounts()),
37 404 => Operation.response("Not Found", "application/json", ApiError)
38 }
39 }
40 end
41 end