From c7c24dd65bbbba518dd79479361731e87b9dbc21 Mon Sep 17 00:00:00 2001 From: Samuel Lissner Date: Sat, 9 Feb 2019 19:08:53 +0100 Subject: [PATCH 1/2] 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 From 1e18bb40643c68d24d3a6e2aa8921bdc2166fba2 Mon Sep 17 00:00:00 2001 From: Samuel Lissner Date: Sat, 9 Feb 2019 23:00:11 +0100 Subject: [PATCH 2/2] Comply with phoenix 1.4 requirements of :url --- lib/mix/tasks/swagger.generate.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mix/tasks/swagger.generate.ex b/lib/mix/tasks/swagger.generate.ex index bc9ee95..00ce76e 100644 --- a/lib/mix/tasks/swagger.generate.ex +++ b/lib/mix/tasks/swagger.generate.ex @@ -180,7 +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) + 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 @@ -190,7 +190,7 @@ defmodule Mix.Tasks.Phx.Swagger.Generate do end swagger_map = - if scheme == :https do + if scheme == "https" do Map.put_new(swagger_map, :schemes, ["https", "http"]) else swagger_map