diff --git a/modules/openapi-generator/src/main/resources/elixir/README.md.mustache b/modules/openapi-generator/src/main/resources/elixir/README.md.mustache index 592b9de0043d5a8c2d16546392d3ae8f077eae91..a7b8e8d6a1aabb1abf57e06c583cc89db2e03ede 100644 --- a/modules/openapi-generator/src/main/resources/elixir/README.md.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/README.md.mustache @@ -24,3 +24,11 @@ end Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) and published on [HexDocs](https://hexdocs.pm). Once published, the docs can be found at [https://hexdocs.pm/{{#underscored}}{{packageName}}{{/underscored}}](https://hexdocs.pm/{{#underscored}}{{packageName}}{{/underscored}}). + + +## Configuration + +You can override the URL of your server (e.g. if you have a separate development and production server in your configuration files. +```elixir +config :{{#underscored}}{{appName}}{{/underscored}}, base_url: "{{{basePath}}}" +``` \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache b/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache index 810281e039ac6993202c9df3ef8f265d79e33275..da8f554eb7b71f545d98b132bab0815af08ae32f 100644 --- a/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache @@ -21,6 +21,8 @@ use Mix.Config # config :logger, level: :info # +config :{{#underscored}}{{appName}}{{/underscored}}, base_url: "{{{basePath}}}" + # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. diff --git a/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache index fe86fe1f06b7b7f7028a41cb08e550a6aa55d477..60ec9e3e2547f1007b424de8c02de56061cf35c5 100644 --- a/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache @@ -7,7 +7,7 @@ defmodule {{moduleName}}.Connection do use Tesla # Add any middleware here (authentication) - plug Tesla.Middleware.BaseUrl, "{{{basePath}}}" + plug Tesla.Middleware.BaseUrl, Application.get_env(:{{#underscored}}{{appName}}{{/underscored}}, :base_url, "{{{basePath}}}") plug Tesla.Middleware.Headers, [{"user-agent", "Elixir"}] plug Tesla.Middleware.EncodeJson, engine: Poison diff --git a/samples/client/petstore/elixir/README.md b/samples/client/petstore/elixir/README.md index e268e77389ac5a55851db7cdd3389fd2f88f01a4..42caba912a8bf5881bc269d6b615e9a07fbec8e9 100644 --- a/samples/client/petstore/elixir/README.md +++ b/samples/client/petstore/elixir/README.md @@ -24,3 +24,11 @@ end Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) and published on [HexDocs](https://hexdocs.pm). Once published, the docs can be found at [https://hexdocs.pm/openapi_petstore](https://hexdocs.pm/openapi_petstore). + + +## Configuration + +You can override the URL of your server (e.g. if you have a separate development and production server in your configuration files. +```elixir +config :open_api_petstore, base_url: "http://petstore.swagger.io:80/v2" +``` \ No newline at end of file diff --git a/samples/client/petstore/elixir/config/config.exs b/samples/client/petstore/elixir/config/config.exs index 72508194de35d0f9a282600b8178392065125893..e2fdf3c3b4579d262bb7b8373b5101d1a8c11fbb 100644 --- a/samples/client/petstore/elixir/config/config.exs +++ b/samples/client/petstore/elixir/config/config.exs @@ -21,6 +21,8 @@ use Mix.Config # config :logger, level: :info # +config :open_api_petstore, base_url: "http://petstore.swagger.io:80/v2" + # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex index 4bc4ae17ce96b1658342e50c9bcbf8d59f9992e5..926fcb505357beb0455680f197b0dbf270c014ad 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex @@ -10,7 +10,7 @@ defmodule OpenapiPetstore.Connection do use Tesla # Add any middleware here (authentication) - plug Tesla.Middleware.BaseUrl, "http://petstore.swagger.io:80/v2" + plug Tesla.Middleware.BaseUrl, Application.get_env(:open_api_petstore, :base_url, "http://petstore.swagger.io:80/v2") plug Tesla.Middleware.Headers, [{"user-agent", "Elixir"}] plug Tesla.Middleware.EncodeJson, engine: Poison