Apix v0.2.2 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 true
...> @moduledoc "Example api"
...> @doc "Example function"
...> def test(_), 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
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
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"]
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"}