zhongwencool / maxwell

Maxwell is an HTTP client which support for middleware and multiple adapters.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to controll Maxwell.Builder docs generation

visciang opened this issue · comments

In order to avoid the generation of the docs attached to the generated http methods function, it could be useful to add a "use" option to control this behaviour.

My use case is keeping clean the API clients generated documentation with only the specific client functions.

For example, something like:

use Maxwell.Builder, docs: false

To be backward compatible we should support both:

  • The "current" form:
use Maxwell.Builder, [:get, :post]
  • The "new" form:
use Maxwell.Builder, docs: false, methods: [:get, :post]

If this is welcome I will open a PR.

@visciang Firstly, this will lead to a fundamental change for the API, so not feasible at least for this version. For your scenario, I suggest you create another module (besides your Client module) to hold the Maxwell, and then import it into your Client module. You can try something like

defmodule MaxwellAdapter do
  use Maxwell.Builder
  #setup the maxwell
end
defmodule CleanClient do
  import MaxwellAdapter
  def anEndpoint do
    new(url) |> post()
  end
end

Hope this helps.

OK! Thank you!