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 Pleroma.Web.Endpoint
8 alias Pleroma.Web.Router
16 # Populate the Server info from a phoenix endpoint
17 OpenApiSpex.Server.from_endpoint(Endpoint)
19 info: %OpenApiSpex.Info{
21 description: Application.spec(:pleroma, :description) |> to_string(),
22 version: Application.spec(:pleroma, :vsn) |> to_string()
24 # populate the paths from a phoenix router
25 paths: OpenApiSpex.Paths.from_router(Router),
26 components: %OpenApiSpex.Components{
28 "oAuth" => %OpenApiSpex.SecurityScheme{
30 flows: %OpenApiSpex.OAuthFlows{
31 password: %OpenApiSpex.OAuthFlow{
32 authorizationUrl: "/oauth/authorize",
33 tokenUrl: "/oauth/token",
34 scopes: %{"read" => "read", "write" => "write"}
41 # discover request/response schemas from path specs
42 |> OpenApiSpex.resolve_schema_modules()