summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/api_spec/schemas/status.ex
blob: 486c3a0fe2130b9947db4e0aea988b996f469827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.ApiSpec.Schemas.Status do
  alias OpenApiSpex.Schema
  alias Pleroma.Web.ApiSpec.Schemas.Account
  alias Pleroma.Web.ApiSpec.Schemas.AccountEmoji
  alias Pleroma.Web.ApiSpec.Schemas.Poll
  alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope

  require OpenApiSpex

  OpenApiSpex.schema(%{
    title: "Status",
    description: "Response schema for a status",
    type: :object,
    properties: %{
      account: Account,
      application: %Schema{
        type: :object,
        properties: %{
          name: %Schema{type: :string},
          website: %Schema{type: :string, nullable: true}
        }
      },
      bookmarked: %Schema{type: :boolean},
      card: %Schema{
        type: :object,
        nullable: true,
        properties: %{
          type: %Schema{type: :string},
          provider_name: %Schema{type: :string},
          provider_url: %Schema{type: :string},
          url: %Schema{type: :string},
          image: %Schema{type: :string},
          title: %Schema{type: :string},
          description: %Schema{type: :string}
        }
      },
      content: %Schema{type: :string},
      created_at: %Schema{type: :string, format: "date-time"},
      emojis: %Schema{type: :array, items: AccountEmoji},
      favourited: %Schema{type: :boolean},
      favourites_count: %Schema{type: :integer},
      id: %Schema{type: :string},
      in_reply_to_account_id: %Schema{type: :string, nullable: true},
      in_reply_to_id: %Schema{type: :string, nullable: true},
      language: %Schema{type: :string, nullable: true},
      media_attachments: %Schema{
        type: :array,
        items: %Schema{
          type: :object,
          properties: %{
            id: %Schema{type: :string},
            url: %Schema{type: :string},
            remote_url: %Schema{type: :string},
            preview_url: %Schema{type: :string},
            text_url: %Schema{type: :string},
            description: %Schema{type: :string},
            type: %Schema{type: :string, enum: ["image", "video", "audio", "unknown"]},
            pleroma: %Schema{
              type: :object,
              properties: %{mime_type: %Schema{type: :string}}
            }
          }
        }
      },
      mentions: %Schema{
        type: :array,
        items: %Schema{
          type: :object,
          properties: %{
            id: %Schema{type: :string},
            acct: %Schema{type: :string},
            username: %Schema{type: :string},
            url: %Schema{type: :string}
          }
        }
      },
      muted: %Schema{type: :boolean},
      pinned: %Schema{type: :boolean},
      pleroma: %Schema{
        type: :object,
        properties: %{
          content: %Schema{type: :object, additionalProperties: %Schema{type: :string}},
          conversation_id: %Schema{type: :integer},
          direct_conversation_id: %Schema{type: :string, nullable: true},
          emoji_reactions: %Schema{
            type: :array,
            items: %Schema{
              type: :object,
              properties: %{
                name: %Schema{type: :string},
                count: %Schema{type: :integer},
                me: %Schema{type: :boolean}
              }
            }
          },
          expires_at: %Schema{type: :string, format: "date-time", nullable: true},
          in_reply_to_account_acct: %Schema{type: :string, nullable: true},
          local: %Schema{type: :boolean},
          spoiler_text: %Schema{type: :object, additionalProperties: %Schema{type: :string}},
          thread_muted: %Schema{type: :boolean}
        }
      },
      poll: %Schema{type: Poll, nullable: true},
      reblog: %Schema{
        allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
        nullable: true
      },
      reblogged: %Schema{type: :boolean},
      reblogs_count: %Schema{type: :integer},
      replies_count: %Schema{type: :integer},
      sensitive: %Schema{type: :boolean},
      spoiler_text: %Schema{type: :string},
      tags: %Schema{
        type: :array,
        items: %Schema{
          type: :object,
          properties: %{
            name: %Schema{type: :string},
            url: %Schema{type: :string}
          }
        }
      },
      uri: %Schema{type: :string},
      url: %Schema{type: :string},
      visibility: VisibilityScope
    },
    example: %{
      "JSON" => %{
        "account" => %{
          "acct" => "nick6",
          "avatar" => "http://localhost:4001/images/avi.png",
          "avatar_static" => "http://localhost:4001/images/avi.png",
          "bot" => false,
          "created_at" => "2020-04-07T19:48:51.000Z",
          "display_name" => "Test テスト User 6",
          "emojis" => [],
          "fields" => [],
          "followers_count" => 1,
          "following_count" => 0,
          "header" => "http://localhost:4001/images/banner.png",
          "header_static" => "http://localhost:4001/images/banner.png",
          "id" => "9toJCsKN7SmSf3aj5c",
          "locked" => false,
          "note" => "Tester Number 6",
          "pleroma" => %{
            "background_image" => nil,
            "confirmation_pending" => false,
            "hide_favorites" => true,
            "hide_followers" => false,
            "hide_followers_count" => false,
            "hide_follows" => false,
            "hide_follows_count" => false,
            "is_admin" => false,
            "is_moderator" => false,
            "relationship" => %{
              "blocked_by" => false,
              "blocking" => false,
              "domain_blocking" => false,
              "endorsed" => false,
              "followed_by" => false,
              "following" => true,
              "id" => "9toJCsKN7SmSf3aj5c",
              "muting" => false,
              "muting_notifications" => false,
              "requested" => false,
              "showing_reblogs" => true,
              "subscribing" => false
            },
            "skip_thread_containment" => false,
            "tags" => []
          },
          "source" => %{
            "fields" => [],
            "note" => "Tester Number 6",
            "pleroma" => %{"actor_type" => "Person", "discoverable" => false},
            "sensitive" => false
          },
          "statuses_count" => 1,
          "url" => "http://localhost:4001/users/nick6",
          "username" => "nick6"
        },
        "application" => %{"name" => "Web", "website" => nil},
        "bookmarked" => false,
        "card" => nil,
        "content" => "foobar",
        "created_at" => "2020-04-07T19:48:51.000Z",
        "emojis" => [],
        "favourited" => false,
        "favourites_count" => 0,
        "id" => "9toJCu5YZW7O7gfvH6",
        "in_reply_to_account_id" => nil,
        "in_reply_to_id" => nil,
        "language" => nil,
        "media_attachments" => [],
        "mentions" => [],
        "muted" => false,
        "pinned" => false,
        "pleroma" => %{
          "content" => %{"text/plain" => "foobar"},
          "conversation_id" => 345_972,
          "direct_conversation_id" => nil,
          "emoji_reactions" => [],
          "expires_at" => nil,
          "in_reply_to_account_acct" => nil,
          "local" => true,
          "spoiler_text" => %{"text/plain" => ""},
          "thread_muted" => false
        },
        "poll" => nil,
        "reblog" => nil,
        "reblogged" => false,
        "reblogs_count" => 0,
        "replies_count" => 0,
        "sensitive" => false,
        "spoiler_text" => "",
        "tags" => [],
        "uri" => "http://localhost:4001/objects/0f5dad44-0e9e-4610-b377-a2631e499190",
        "url" => "http://localhost:4001/notice/9toJCu5YZW7O7gfvH6",
        "visibility" => "private"
      }
    }
  })
end