OpenAPI: make it possible to generate a spec without starting the app
authorrinpatch <rinpatch@sdf.org>
Fri, 18 Sep 2020 21:50:38 +0000 (00:50 +0300)
committerrinpatch <rinpatch@sdf.org>
Sat, 19 Sep 2020 13:26:15 +0000 (16:26 +0300)
Needed for api docs generation on pleroma.social that will come later

lib/pleroma/web/api_spec.ex

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