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"},
41 items: %Schema{type: :string},
42 description: "Array of Statuses to attach to the report, for context"
47 description: "Reason for the report"
54 "If the account is remote, should the report be forwarded to the remote admin?"
57 required: [:account_id],
59 "account_id" => "123",
60 "status_ids" => ["1337"],
61 "comment" => "bad status!",
67 defp create_response do
69 title: "ReportResponse",
72 id: %Schema{type: :string, description: "Report ID"},
73 action_taken: %Schema{type: :boolean, description: "Is action taken?"}
77 "action_taken" => false