1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 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 # Populate the Server info from a phoenix endpoint
18 OpenApiSpex.Server.from_endpoint(Endpoint)
20 info: %OpenApiSpex.Info{
22 description: Application.spec(:pleroma, :description) |> to_string(),
23 version: Application.spec(:pleroma, :vsn) |> to_string()
25 # populate the paths from a phoenix router
26 paths: OpenApiSpex.Paths.from_router(Router),
27 components: %OpenApiSpex.Components{
29 "accountIdOrNickname" =>
30 Operation.parameter(:id, :path, :string, "Account ID or nickname",
36 "oAuth" => %OpenApiSpex.SecurityScheme{
38 flows: %OpenApiSpex.OAuthFlows{
39 password: %OpenApiSpex.OAuthFlow{
40 authorizationUrl: "/oauth/authorize",
41 tokenUrl: "/oauth/token",
54 # discover request/response schemas from path specs
55 |> OpenApiSpex.resolve_schema_modules()