From c7c24dd65bbbba518dd79479361731e87b9dbc21 Mon Sep 17 00:00:00 2001 From: Samuel Lissner Date: Sat, 9 Feb 2019 19:08:53 +0100 Subject: [PATCH] Derive schemes from endpoint :url --- .gitignore | 2 ++ lib/mix/tasks/swagger.generate.ex | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index 755b605..b9b1455 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /deps erl_crash.dump *.ez +.idea/ +*.iml diff --git a/lib/mix/tasks/swagger.generate.ex b/lib/mix/tasks/swagger.generate.ex index c64bdcb..bc9ee95 100644 --- a/lib/mix/tasks/swagger.generate.ex +++ b/lib/mix/tasks/swagger.generate.ex @@ -180,6 +180,7 @@ defmodule Mix.Tasks.Phx.Swagger.Generate do url = Keyword.get(endpoint_config, :url) host = Keyword.get(url, :host, "localhost") port = Keyword.get(url, :port, 4000) + scheme = Keyword.get(url, :scheme, :http) swagger_map = if (!load_from_system_env) and is_binary(host) and (is_integer(port) or is_binary(port)) do @@ -188,6 +189,13 @@ defmodule Mix.Tasks.Phx.Swagger.Generate do swagger_map # host / port may be {:system, "ENV_VAR"} tuples or loaded in Endpoint.init callback end + swagger_map = + if scheme == :https do + Map.put_new(swagger_map, :schemes, ["https", "http"]) + else + swagger_map + end + case endpoint_config[:https] do nil -> swagger_map