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
11 def open_api_operation(action) do
12 operation = String.to_existing_atom("#{action}_operation")
13 apply(__MODULE__, operation, [])
16 def create_operation do
19 summary: "File a report",
20 description: "Report problematic users to your moderators",
21 operationId: "ReportController.create",
22 security: [%{"oAuth" => ["follow", "write:reports"]}],
23 requestBody: Helpers.request_body("Parameters", create_request(), required: true),
25 200 => Operation.response("Report", "application/json", create_response()),
26 400 => Operation.response("Report", "application/json", ApiError)
31 defp create_request do
33 title: "ReportCreateRequest",
34 description: "POST body for creating a report",
37 account_id: %Schema{type: :string, description: "ID of the account to report"},
40 items: %Schema{type: :string},
41 description: "Array of Statuses to attach to the report, for context"
45 description: "Reason for the report"
51 "If the account is remote, should the report be forwarded to the remote admin?"
54 required: [:account_id],
56 "account_id" => "123",
57 "status_ids" => ["1337"],
58 "comment" => "bad status!",
64 defp create_response do
66 title: "ReportResponse",
69 id: %Schema{type: :string, description: "Report ID"},
70 action_taken: %Schema{type: :boolean, description: "Is action taken?"}
74 "action_taken" => false