1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.PollOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
10 alias Pleroma.Web.ApiSpec.Schemas.Poll
12 import Pleroma.Web.ApiSpec.Helpers
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
22 summary: "View a poll",
23 security: [%{"oAuth" => ["read:statuses"]}],
24 parameters: [id_param()],
25 operationId: "PollController.show",
27 200 => Operation.response("Poll", "application/json", Poll),
28 404 => Operation.response("Error", "application/json", ApiError)
36 summary: "Vote on a poll",
37 parameters: [id_param()],
38 operationId: "PollController.vote",
39 requestBody: vote_request(),
40 security: [%{"oAuth" => ["write:statuses"]}],
42 200 => Operation.response("Poll", "application/json", Poll),
43 422 => Operation.response("Error", "application/json", ApiError),
44 404 => Operation.response("Error", "application/json", ApiError)
50 Operation.parameter(:id, :path, FlakeID, "Poll ID",
64 items: %Schema{type: :integer},
65 description: "Array of own votes containing index for each option (starting from 0)"
72 "choices" => [0, 1, 2]