Merge branch 'develop' into 'remove-twitter-api'
[akkoma] / lib / pleroma / web / api_spec / schemas / poll.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.Schemas.Poll do
6 alias OpenApiSpex.Schema
7 alias Pleroma.Web.ApiSpec.Schemas.Emoji
8 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
9
10 require OpenApiSpex
11
12 OpenApiSpex.schema(%{
13 title: "Poll",
14 description: "Represents a poll attached to a status",
15 type: :object,
16 properties: %{
17 id: FlakeID,
18 expires_at: %Schema{
19 type: :string,
20 format: :"date-time",
21 nullable: true,
22 description: "When the poll ends"
23 },
24 expired: %Schema{type: :boolean, description: "Is the poll currently expired?"},
25 multiple: %Schema{
26 type: :boolean,
27 description: "Does the poll allow multiple-choice answers?"
28 },
29 votes_count: %Schema{
30 type: :integer,
31 nullable: true,
32 description: "How many votes have been received. Number, or null if `multiple` is false."
33 },
34 voted: %Schema{
35 type: :boolean,
36 nullable: true,
37 description:
38 "When called with a user token, has the authorized user voted? Boolean, or null if no current user."
39 },
40 emojis: %Schema{
41 type: :array,
42 items: Emoji,
43 description: "Custom emoji to be used for rendering poll options."
44 },
45 options: %Schema{
46 type: :array,
47 items: %Schema{
48 title: "PollOption",
49 type: :object,
50 properties: %{
51 title: %Schema{type: :string},
52 votes_count: %Schema{type: :integer}
53 }
54 },
55 description: "Possible answers for the poll."
56 }
57 },
58 example: %{
59 id: "34830",
60 expires_at: "2019-12-05T04:05:08.302Z",
61 expired: true,
62 multiple: false,
63 votes_count: 10,
64 voters_count: nil,
65 voted: true,
66 own_votes: [
67 1
68 ],
69 options: [
70 %{
71 title: "accept",
72 votes_count: 6
73 },
74 %{
75 title: "deny",
76 votes_count: 4
77 }
78 ],
79 emojis: []
80 }
81 })
82 end