First
[anni] / lib / pleroma / web / api_spec / operations / pleroma_app_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.PleromaAppOperation do
6   alias OpenApiSpex.Operation
7   alias OpenApiSpex.Schema
8   alias Pleroma.Web.ApiSpec.Schemas.App
9
10   def open_api_operation(action) do
11     operation = String.to_existing_atom("#{action}_operation")
12     apply(__MODULE__, operation, [])
13   end
14
15   @spec index_operation() :: Operation.t()
16   def index_operation do
17     %Operation{
18       tags: ["Applications"],
19       summary: "List applications",
20       description: "List the OAuth applications for the current user",
21       operationId: "AppController.index",
22       responses: %{
23         200 => Operation.response("Array of App", "application/json", array_of_apps())
24       }
25     }
26   end
27
28   defp array_of_apps do
29     %Schema{type: :array, items: App, example: [App.schema().example]}
30   end
31 end