1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec do
6 alias OpenApiSpex.OpenApi
7 alias OpenApiSpex.Operation
8 alias Pleroma.Web.Endpoint
9 alias Pleroma.Web.Router
17 if Phoenix.Endpoint.server?(:pleroma, Endpoint) do
19 # Populate the Server info from a phoenix endpoint
20 OpenApiSpex.Server.from_endpoint(Endpoint)
25 info: %OpenApiSpex.Info{
27 description: Application.spec(:pleroma, :description) |> to_string(),
28 version: Application.spec(:pleroma, :vsn) |> to_string()
30 # populate the paths from a phoenix router
31 paths: OpenApiSpex.Paths.from_router(Router),
32 components: %OpenApiSpex.Components{
34 "accountIdOrNickname" =>
35 Operation.parameter(:id, :path, :string, "Account ID or nickname",
41 "oAuth" => %OpenApiSpex.SecurityScheme{
43 flows: %OpenApiSpex.OAuthFlows{
44 password: %OpenApiSpex.OAuthFlow{
45 authorizationUrl: "/oauth/authorize",
46 tokenUrl: "/oauth/token",
59 # discover request/response schemas from path specs
60 |> OpenApiSpex.resolve_schema_modules()