OpenAPI: make it possible to generate a spec without starting the app

Needed for api docs generation on pleroma.social that will come later
This commit is contained in:
rinpatch 2020-09-19 00:50:38 +03:00
parent 51116b5392
commit 4b12e071ac
1 changed files with 9 additions and 4 deletions

View File

@ -13,10 +13,15 @@ defmodule Pleroma.Web.ApiSpec do
@impl OpenApi @impl OpenApi
def spec do def spec do
%OpenApi{ %OpenApi{
servers: [ servers:
# Populate the Server info from a phoenix endpoint if Phoenix.Endpoint.server?(:pleroma, Endpoint) do
OpenApiSpex.Server.from_endpoint(Endpoint) [
], # Populate the Server info from a phoenix endpoint
OpenApiSpex.Server.from_endpoint(Endpoint)
]
else
[]
end,
info: %OpenApiSpex.Info{ info: %OpenApiSpex.Info{
title: "Pleroma", title: "Pleroma",
description: Application.spec(:pleroma, :description) |> to_string(), description: Application.spec(:pleroma, :description) |> to_string(),