Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive schemes from endpoint :url #222

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest ignoring IDE generated files globally in your git config so they don’t need to be ignored in each repo.

*.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"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is plain http included for local development, even if the production endpoint is always https ?

else
swagger_map
end

case endpoint_config[:https] do
nil ->
swagger_map
Expand Down