Use `json_response_and_validate_schema/2` in tests to validate OpenAPI schema
[akkoma] / lib / pleroma / web / api_spec / schemas / account_update_credentials_request.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.AccountUpdateCredentialsRequest do
6 alias OpenApiSpex.Schema
7 alias Pleroma.Web.ApiSpec.Schemas.AccountAttributeField
8 alias Pleroma.Web.ApiSpec.Schemas.ActorType
9 alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
10 require OpenApiSpex
11
12 OpenApiSpex.schema(%{
13 title: "AccountUpdateCredentialsRequest",
14 description: "POST body for creating an account",
15 type: :object,
16 properties: %{
17 bot: %Schema{
18 type: :boolean,
19 description: "Whether the account has a bot flag."
20 },
21 display_name: %Schema{
22 type: :string,
23 description: "The display name to use for the profile."
24 },
25 note: %Schema{type: :string, description: "The account bio."},
26 avatar: %Schema{
27 type: :string,
28 description: "Avatar image encoded using multipart/form-data",
29 format: :binary
30 },
31 header: %Schema{
32 type: :string,
33 description: "Header image encoded using multipart/form-data",
34 format: :binary
35 },
36 locked: %Schema{
37 type: :boolean,
38 description: "Whether manual approval of follow requests is required."
39 },
40 fields_attributes: %Schema{
41 oneOf: [
42 %Schema{type: :array, items: AccountAttributeField},
43 %Schema{type: :object, additionalProperties: %Schema{type: AccountAttributeField}}
44 ]
45 },
46 # NOTE: `source` field is not supported
47 #
48 # source: %Schema{
49 # type: :object,
50 # properties: %{
51 # privacy: %Schema{type: :string},
52 # sensitive: %Schema{type: :boolean},
53 # language: %Schema{type: :string}
54 # }
55 # },
56
57 # Pleroma-specific fields
58 no_rich_text: %Schema{
59 type: :boolean,
60 description: "html tags are stripped from all statuses requested from the API"
61 },
62 hide_followers: %Schema{type: :boolean, description: "user's followers will be hidden"},
63 hide_follows: %Schema{type: :boolean, description: "user's follows will be hidden"},
64 hide_followers_count: %Schema{
65 type: :boolean,
66 description: "user's follower count will be hidden"
67 },
68 hide_follows_count: %Schema{
69 type: :boolean,
70 description: "user's follow count will be hidden"
71 },
72 hide_favorites: %Schema{
73 type: :boolean,
74 description: "user's favorites timeline will be hidden"
75 },
76 show_role: %Schema{
77 type: :boolean,
78 description: "user's role (e.g admin, moderator) will be exposed to anyone in the
79 API"
80 },
81 default_scope: VisibilityScope,
82 pleroma_settings_store: %Schema{
83 type: :object,
84 description: "Opaque user settings to be saved on the backend."
85 },
86 skip_thread_containment: %Schema{
87 type: :boolean,
88 description: "Skip filtering out broken threads"
89 },
90 allow_following_move: %Schema{
91 type: :boolean,
92 description: "Allows automatically follow moved following accounts"
93 },
94 pleroma_background_image: %Schema{
95 type: :string,
96 description: "Sets the background image of the user.",
97 format: :binary
98 },
99 discoverable: %Schema{
100 type: :boolean,
101 description: "Discovery of this account in search results and other services is allowed."
102 },
103 actor_type: ActorType
104 },
105 example: %{
106 bot: false,
107 display_name: "cofe",
108 note: "foobar",
109 fields_attributes: [%{name: "foo", value: "bar"}],
110 no_rich_text: false,
111 hide_followers: true,
112 hide_follows: false,
113 hide_followers_count: false,
114 hide_follows_count: false,
115 hide_favorites: false,
116 show_role: false,
117 default_scope: "private",
118 pleroma_settings_store: %{"pleroma-fe" => %{"key" => "val"}},
119 skip_thread_containment: false,
120 allow_following_move: false,
121 discoverable: false,
122 actor_type: "Person"
123 }
124 })
125 end