Apix v0.2.0 Apix View Source

Apix allows use native elixir documentation format for documenting APIs.

Example

iex> defmodule Test.Api do
...>   use Apix
...>   @name "Test"
...>   @namespace "test"
...>   api "Test", :foo
...>   @moduledoc "Example api"
...>   @doc "Example function"
...>   def foo(_), do: :bar
...> end
iex> Apix.spec(Test.Api, :methods)
["Test"]
iex> Apix.apply(Test.Api, "Test", %{})
:bar

For more introspection rules, see spec/1, spec/2, spec/3 functions.

There are some word in documetation, which will be identified, for example: ## Parameters, starting the attributes section.

Each attribute should have the same format: " key - type, description" or " key - type, optional, description". Type should be of type, which your validator supports.

Link to this section Summary

Functions

This macro, defines the binding between symbolic method name and exported elixir function. And defines, which function should be exported as API method.

Apply method on arguments

Get api description of a module.

Get specification of a module and defined methods in it.

Get specification of a method in module and parameters in it.

Link to this section Functions

Link to this macro

api(method, function, args \\ [])

View Source (macro)

This macro, defines the binding between symbolic method name and exported elixir function. And defines, which function should be exported as API method.

Link to this function

apply(module, method, args)

View Source

Apply method on arguments

Example

iex> Apix.apply(Simple.Api, "Put", %{key: "foo", value: "bar"})
%{result: true}
iex> Apix.apply(Simple.Api, "Get", %{key: "foo"})
%{result: "bar"}

Get api description of a module.

Example

iex> Apix.spec(Simple.Api)
"store"

Get specification of a module and defined methods in it.

Example

iex> Apix.spec(Simple.Api, :name)
"SimpleStore"
iex> Apix.spec(Simple.Api, :doc)
"This api describes very simple get/put storage api.\nAnd should be a very small example of how to use it.\n"
iex> Apix.spec(Simple.Api, :methods)
["Get", "Put"]
Link to this function

spec(module, atom, method)

View Source

Get specification of a method in module and parameters in it.

Example

iex> Apix.spec(Simple.Api, :method, "Put")
%{arguments: [key: %{description: "describes key, on which it will be saved", optional: false, type: "string"},
            value: %{description: "describes value", optional: false, type: "string"}],
  doc: "Put a value for the key"}