Add spec for AccountController.create
[akkoma] / lib / pleroma / web / api_spec / render_error.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.RenderError do
6 @behaviour Plug
7
8 alias Plug.Conn
9 alias OpenApiSpex.Plug.JsonRenderError
10
11 @impl Plug
12 def init(opts), do: opts
13
14 @impl Plug
15
16 def call(%{private: %{open_api_spex: %{operation_id: "AccountController.create"}}} = conn, _) do
17 conn
18 |> Conn.put_status(:bad_request)
19 |> Phoenix.Controller.json(%{"error" => "Missing parameters"})
20 end
21
22 def call(conn, reason) do
23 opts = JsonRenderError.init(reason)
24
25 JsonRenderError.call(conn, opts)
26 end
27 end