Add spec for AccountController.show
This commit is contained in:
parent
d7d6a83233
commit
278b3fa0ad
@ -86,7 +86,21 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
||||
end
|
||||
|
||||
def show_operation do
|
||||
:ok
|
||||
%Operation{
|
||||
tags: ["accounts"],
|
||||
summary: "Account",
|
||||
operationId: "AccountController.show",
|
||||
description: "View information about a profile.",
|
||||
parameters: [
|
||||
Operation.parameter(:id, :path, :string, "Account ID or nickname",
|
||||
example: "123",
|
||||
required: true
|
||||
)
|
||||
],
|
||||
responses: %{
|
||||
200 => Operation.response("Account", "application/json", Account)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def statuses_operation do
|
||||
|
@ -83,7 +83,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||
plug(
|
||||
OpenApiSpex.Plug.CastAndValidate,
|
||||
[render_error: Pleroma.Web.ApiSpec.RenderError]
|
||||
when action in [:create, :verify_credentials, :update_credentials, :relationships]
|
||||
when action in [:create, :verify_credentials, :update_credentials, :relationships, :show]
|
||||
)
|
||||
|
||||
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
||||
@ -239,7 +239,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||
def relationships(%{assigns: %{user: _user}} = conn, _), do: json(conn, [])
|
||||
|
||||
@doc "GET /api/v1/accounts/:id"
|
||||
def show(%{assigns: %{user: for_user}} = conn, %{"id" => nickname_or_id}) do
|
||||
def show(%{assigns: %{user: for_user}} = conn, %{id: nickname_or_id}) do
|
||||
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname_or_id, for: for_user),
|
||||
true <- User.visible_for?(user, for_user) do
|
||||
render(conn, "show.json", user: user, for: for_user)
|
||||
|
@ -3,7 +3,7 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ApiSpec.AccountOperationTest do
|
||||
use Pleroma.Web.ConnCase, async: true
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Web.ApiSpec
|
||||
alias Pleroma.Web.ApiSpec.Schemas.Account
|
||||
@ -108,4 +108,18 @@ defmodule Pleroma.Web.ApiSpec.AccountOperationTest do
|
||||
|
||||
assert_schema([relationship], "AccountRelationshipsResponse", api_spec)
|
||||
end
|
||||
|
||||
test "/api/v1/accounts/:id produces Account", %{
|
||||
conn: conn
|
||||
} do
|
||||
user = insert(:user)
|
||||
api_spec = ApiSpec.spec()
|
||||
|
||||
assert resp =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{user.id}")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert_schema(resp, "Account", api_spec)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user