Merge branch 'openapi/lists' into 'develop'
[akkoma] / lib / pleroma / web / api_spec / schemas / status.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.Status do
6 alias OpenApiSpex.Schema
7 alias Pleroma.Web.ApiSpec.Schemas.Account
8 alias Pleroma.Web.ApiSpec.Schemas.Attachment
9 alias Pleroma.Web.ApiSpec.Schemas.Emoji
10 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
11 alias Pleroma.Web.ApiSpec.Schemas.Poll
12 alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
13
14 require OpenApiSpex
15
16 OpenApiSpex.schema(%{
17 title: "Status",
18 description: "Response schema for a status",
19 type: :object,
20 properties: %{
21 account: Account,
22 application: %Schema{
23 type: :object,
24 properties: %{
25 name: %Schema{type: :string},
26 website: %Schema{type: :string, nullable: true, format: :uri}
27 }
28 },
29 bookmarked: %Schema{type: :boolean},
30 card: %Schema{
31 type: :object,
32 nullable: true,
33 properties: %{
34 type: %Schema{type: :string, enum: ["link", "photo", "video", "rich"]},
35 provider_name: %Schema{type: :string, nullable: true},
36 provider_url: %Schema{type: :string, format: :uri},
37 url: %Schema{type: :string, format: :uri},
38 image: %Schema{type: :string, nullable: true, format: :uri},
39 title: %Schema{type: :string},
40 description: %Schema{type: :string}
41 }
42 },
43 content: %Schema{type: :string, format: :html},
44 created_at: %Schema{type: :string, format: "date-time"},
45 emojis: %Schema{type: :array, items: Emoji},
46 favourited: %Schema{type: :boolean},
47 favourites_count: %Schema{type: :integer},
48 id: FlakeID,
49 in_reply_to_account_id: %Schema{type: :string, nullable: true},
50 in_reply_to_id: %Schema{type: :string, nullable: true},
51 language: %Schema{type: :string, nullable: true},
52 media_attachments: %Schema{
53 type: :array,
54 items: Attachment
55 },
56 mentions: %Schema{
57 type: :array,
58 items: %Schema{
59 type: :object,
60 properties: %{
61 id: %Schema{type: :string},
62 acct: %Schema{type: :string},
63 username: %Schema{type: :string},
64 url: %Schema{type: :string, format: :uri}
65 }
66 }
67 },
68 muted: %Schema{type: :boolean},
69 pinned: %Schema{type: :boolean},
70 pleroma: %Schema{
71 type: :object,
72 properties: %{
73 content: %Schema{type: :object, additionalProperties: %Schema{type: :string}},
74 conversation_id: %Schema{type: :integer},
75 direct_conversation_id: %Schema{
76 type: :integer,
77 nullable: true,
78 description:
79 "The ID of the Mastodon direct message conversation the status is associated with (if any)"
80 },
81 emoji_reactions: %Schema{
82 type: :array,
83 items: %Schema{
84 type: :object,
85 properties: %{
86 name: %Schema{type: :string},
87 count: %Schema{type: :integer},
88 me: %Schema{type: :boolean}
89 }
90 }
91 },
92 expires_at: %Schema{type: :string, format: "date-time", nullable: true},
93 in_reply_to_account_acct: %Schema{type: :string, nullable: true},
94 local: %Schema{type: :boolean},
95 spoiler_text: %Schema{type: :object, additionalProperties: %Schema{type: :string}},
96 thread_muted: %Schema{type: :boolean}
97 }
98 },
99 poll: %Schema{type: Poll, nullable: true},
100 reblog: %Schema{
101 allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
102 nullable: true
103 },
104 reblogged: %Schema{type: :boolean},
105 reblogs_count: %Schema{type: :integer},
106 replies_count: %Schema{type: :integer},
107 sensitive: %Schema{type: :boolean},
108 spoiler_text: %Schema{type: :string},
109 tags: %Schema{
110 type: :array,
111 items: %Schema{
112 type: :object,
113 properties: %{
114 name: %Schema{type: :string},
115 url: %Schema{type: :string, format: :uri}
116 }
117 }
118 },
119 uri: %Schema{type: :string, format: :uri},
120 url: %Schema{type: :string, nullable: true, format: :uri},
121 visibility: VisibilityScope
122 },
123 example: %{
124 "account" => %{
125 "acct" => "nick6",
126 "avatar" => "http://localhost:4001/images/avi.png",
127 "avatar_static" => "http://localhost:4001/images/avi.png",
128 "bot" => false,
129 "created_at" => "2020-04-07T19:48:51.000Z",
130 "display_name" => "Test テスト User 6",
131 "emojis" => [],
132 "fields" => [],
133 "followers_count" => 1,
134 "following_count" => 0,
135 "header" => "http://localhost:4001/images/banner.png",
136 "header_static" => "http://localhost:4001/images/banner.png",
137 "id" => "9toJCsKN7SmSf3aj5c",
138 "locked" => false,
139 "note" => "Tester Number 6",
140 "pleroma" => %{
141 "background_image" => nil,
142 "confirmation_pending" => false,
143 "hide_favorites" => true,
144 "hide_followers" => false,
145 "hide_followers_count" => false,
146 "hide_follows" => false,
147 "hide_follows_count" => false,
148 "is_admin" => false,
149 "is_moderator" => false,
150 "relationship" => %{
151 "blocked_by" => false,
152 "blocking" => false,
153 "domain_blocking" => false,
154 "endorsed" => false,
155 "followed_by" => false,
156 "following" => true,
157 "id" => "9toJCsKN7SmSf3aj5c",
158 "muting" => false,
159 "muting_notifications" => false,
160 "requested" => false,
161 "showing_reblogs" => true,
162 "subscribing" => false
163 },
164 "skip_thread_containment" => false,
165 "tags" => []
166 },
167 "source" => %{
168 "fields" => [],
169 "note" => "Tester Number 6",
170 "pleroma" => %{"actor_type" => "Person", "discoverable" => false},
171 "sensitive" => false
172 },
173 "statuses_count" => 1,
174 "url" => "http://localhost:4001/users/nick6",
175 "username" => "nick6"
176 },
177 "application" => %{"name" => "Web", "website" => nil},
178 "bookmarked" => false,
179 "card" => nil,
180 "content" => "foobar",
181 "created_at" => "2020-04-07T19:48:51.000Z",
182 "emojis" => [],
183 "favourited" => false,
184 "favourites_count" => 0,
185 "id" => "9toJCu5YZW7O7gfvH6",
186 "in_reply_to_account_id" => nil,
187 "in_reply_to_id" => nil,
188 "language" => nil,
189 "media_attachments" => [],
190 "mentions" => [],
191 "muted" => false,
192 "pinned" => false,
193 "pleroma" => %{
194 "content" => %{"text/plain" => "foobar"},
195 "conversation_id" => 345_972,
196 "direct_conversation_id" => nil,
197 "emoji_reactions" => [],
198 "expires_at" => nil,
199 "in_reply_to_account_acct" => nil,
200 "local" => true,
201 "spoiler_text" => %{"text/plain" => ""},
202 "thread_muted" => false
203 },
204 "poll" => nil,
205 "reblog" => nil,
206 "reblogged" => false,
207 "reblogs_count" => 0,
208 "replies_count" => 0,
209 "sensitive" => false,
210 "spoiler_text" => "",
211 "tags" => [],
212 "uri" => "http://localhost:4001/objects/0f5dad44-0e9e-4610-b377-a2631e499190",
213 "url" => "http://localhost:4001/notice/9toJCu5YZW7O7gfvH6",
214 "visibility" => "private"
215 }
216 })
217 end