Merge branch 'openapi/suggestions' into 'develop'

Add OpenAPI spec for SuggestionController

See merge request pleroma/pleroma!2525
This commit is contained in:
lain 2020-05-13 10:34:04 +00:00
commit 6706cdce65
2 changed files with 19 additions and 4 deletions

View File

@ -5,11 +5,26 @@
defmodule Pleroma.Web.MastodonAPI.SuggestionController do
use Pleroma.Web, :controller
alias Pleroma.Plugs.OAuthScopesPlug
require Logger
plug(OAuthScopesPlug, %{scopes: ["read"]} when action == :index)
plug(Pleroma.Web.ApiSpec.CastAndValidate)
plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["read"]} when action == :index)
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
apply(__MODULE__, operation, [])
end
def index_operation do
%OpenApiSpex.Operation{
tags: ["Suggestions"],
summary: "Follow suggestions (Not implemented)",
operationId: "SuggestionController.index",
responses: %{
200 => Pleroma.Web.ApiSpec.Helpers.empty_array_response()
}
}
end
@doc "GET /api/v1/suggestions"
def index(conn, params),

View File

@ -11,7 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
res =
conn
|> get("/api/v1/suggestions")
|> json_response(200)
|> json_response_and_validate_schema(200)
assert res == []
end