1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.ReportOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Helpers
9 alias Pleroma.Web.ApiSpec.Schemas.ApiError
10 alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
12 def open_api_operation(action) do
13 operation = String.to_existing_atom("#{action}_operation")
14 apply(__MODULE__, operation, [])
17 def create_operation do
20 summary: "File a report",
21 description: "Report problematic users to your moderators",
22 operationId: "ReportController.create",
23 security: [%{"oAuth" => ["follow", "write:reports"]}],
24 requestBody: Helpers.request_body("Parameters", create_request(), required: true),
26 200 => Operation.response("Report", "application/json", create_response()),
27 400 => Operation.response("Report", "application/json", ApiError)
32 defp create_request do
34 title: "ReportCreateRequest",
35 description: "POST body for creating a report",
38 account_id: %Schema{type: :string, description: "ID of the account to report"},
42 items: %Schema{type: :string},
43 description: "Array of Statuses to attach to the report, for context"
48 description: "Reason for the report"
55 "If the account is remote, should the report be forwarded to the remote admin?"
58 required: [:account_id],
60 "account_id" => "123",
61 "status_ids" => ["1337"],
62 "comment" => "bad status!",
68 defp create_response do
70 title: "ReportResponse",
73 id: %Schema{type: :string, description: "Report ID"},
74 action_taken: %Schema{type: :boolean, description: "Is action taken?"}
78 "action_taken" => false