Skip to content

Commit

Permalink
Derive schemes from endpoint :url
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Lissner committed Feb 9, 2019
1 parent 650e213 commit c7c24dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/deps
erl_crash.dump
*.ez
.idea/
*.iml
8 changes: 8 additions & 0 deletions lib/mix/tasks/swagger.generate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c7c24dd

Please sign in to comment.