Add spec for AccountController.update_credentials
[akkoma] / lib / pleroma / web / api_spec / operations / account_operation.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.AccountOperation do
6 alias OpenApiSpex.Operation
7 alias Pleroma.Web.ApiSpec.Helpers
8 alias Pleroma.Web.ApiSpec.Schemas.Account
9 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateRequest
10 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateResponse
11 alias Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest
12
13 @spec open_api_operation(atom) :: Operation.t()
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
17 end
18
19 @spec create_operation() :: Operation.t()
20 def create_operation do
21 %Operation{
22 tags: ["accounts"],
23 summary: "Register an account",
24 description:
25 "Creates a user and account records. Returns an account access token for the app that initiated the request. The app should save this token for later, and should wait for the user to confirm their account by clicking a link in their email inbox.",
26 operationId: "AccountController.create",
27 requestBody: Helpers.request_body("Parameters", AccountCreateRequest, required: true),
28 responses: %{
29 200 => Operation.response("Account", "application/json", AccountCreateResponse)
30 }
31 }
32 end
33
34 def verify_credentials_operation do
35 %Operation{
36 tags: ["accounts"],
37 description: "Test to make sure that the user token works.",
38 summary: "Verify account credentials",
39 operationId: "AccountController.verify_credentials",
40 security: [%{"oAuth" => ["read:accounts"]}],
41 responses: %{
42 200 => Operation.response("Account", "application/json", Account)
43 }
44 }
45 end
46
47 def update_credentials_operation do
48 %Operation{
49 tags: ["accounts"],
50 summary: "Update account credentials",
51 description: "Update the user's display and preferences.",
52 operationId: "AccountController.update_credentials",
53 security: [%{"oAuth" => ["write:accounts"]}],
54 requestBody:
55 Helpers.request_body("Parameters", AccountUpdateCredentialsRequest, required: true),
56 responses: %{
57 200 => Operation.response("Account", "application/json", Account)
58 }
59 }
60 end
61
62 def relationships_operation do
63 :ok
64 end
65
66 def show_operation do
67 :ok
68 end
69
70 def statuses_operation do
71 :ok
72 end
73
74 def followers_operation do
75 :ok
76 end
77
78 def following_operation, do: :ok
79 def lists_operation, do: :ok
80 def follow_operation, do: :ok
81 def unfollow_operation, do: :ok
82 def mute_operation, do: :ok
83 def unmute_operation, do: :ok
84 def block_operation, do: :ok
85 def unblock_operation, do: :ok
86 def follows_operation, do: :ok
87 def mutes_operation, do: :ok
88 def blocks_operation, do: :ok
89 def endorsements_operation, do: :ok
90 end