Merge branch 'following-relationships-optimizations' into 'develop'
[akkoma] / lib / pleroma / web / api_spec.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec do
6 alias OpenApiSpex.OpenApi
7 alias Pleroma.Web.Endpoint
8 alias Pleroma.Web.Router
9
10 @behaviour OpenApi
11
12 @impl OpenApi
13 def spec do
14 %OpenApi{
15 servers: [
16 # Populate the Server info from a phoenix endpoint
17 OpenApiSpex.Server.from_endpoint(Endpoint)
18 ],
19 info: %OpenApiSpex.Info{
20 title: "Pleroma",
21 description: Application.spec(:pleroma, :description) |> to_string(),
22 version: Application.spec(:pleroma, :vsn) |> to_string()
23 },
24 # populate the paths from a phoenix router
25 paths: OpenApiSpex.Paths.from_router(Router),
26 components: %OpenApiSpex.Components{
27 securitySchemes: %{
28 "oAuth" => %OpenApiSpex.SecurityScheme{
29 type: "oauth2",
30 flows: %OpenApiSpex.OAuthFlows{
31 password: %OpenApiSpex.OAuthFlow{
32 authorizationUrl: "/oauth/authorize",
33 tokenUrl: "/oauth/token",
34 scopes: %{"read" => "read"}
35 }
36 }
37 }
38 }
39 }
40 }
41 # discover request/response schemas from path specs
42 |> OpenApiSpex.resolve_schema_modules()
43 end
44 end