View Source erf_parser behaviour (erf v0.1.2)

Module that parses a specification file into an API AST.

Summary

Functions

Parses an specification file into an API AST given a specification format.

Types

-type api() ::
          #{name := binary(),
            version := binary(),
            endpoints := [endpoint()],
            schemas := #{ref() => schema()}}.
-type body() :: #{ref := ref(), required := boolean()}.
-type endpoint() :: #{path := path(), parameters := [parameter()], operations := [operation()]}.
-type method() :: erf:method().
-type operation() ::
          #{id := binary(),
            method := method(),
            parameters := [parameter()],
            request := request(),
            responses := #{'*' | status_code() := response()}}.
-type parameter() ::
          #{ref := ref(), name := parameter_name(), type := parameter_type(), required := boolean()}.
-type parameter_name() :: binary().
-type parameter_type() :: header | cookie | path | query.
-type path() :: binary().
-type ref() :: binary().
-type request() :: #{body := body()}.
-type response() :: #{body := body()}.
-type schema() :: ndto:schema().
-type status_code() :: 100..599.

Callbacks

-callback parse(SpecPath) -> Result
                   when
                       SpecPath :: binary(),
                       Result :: {ok, API} | {error, Reason},
                       API :: api(),
                       Reason :: term().

Functions

Link to this function

parse(SpecPath, SpecParser)

View Source
-spec parse(SpecPath, SpecParser) -> Result
               when
                   SpecPath :: binary(),
                   SpecParser :: module(),
                   Result :: {ok, API} | {error, Reason},
                   API :: api(),
                   Reason :: term().
Parses an specification file into an API AST given a specification format.