erf_parser behaviour (erf v0.1.2)

View Source
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

api/0

-type api() ::
          #{name := binary(),
            version := binary(),
            endpoints := [endpoint()],
            schemas := #{ref() => schema()}}.

body/0

-type body() :: #{ref := ref(), required := boolean()}.

endpoint/0

-type endpoint() :: #{path := path(), parameters := [parameter()], operations := [operation()]}.

method/0

-type method() :: erf:method().

operation/0

-type operation() ::
          #{id := binary(),
            method := method(),
            parameters := [parameter()],
            request := request(),
            responses := #{'*' | status_code() := response()}}.

parameter/0

-type parameter() ::
          #{ref := ref(), name := parameter_name(), type := parameter_type(), required := boolean()}.

parameter_name/0

-type parameter_name() :: binary().

parameter_type/0

-type parameter_type() :: header | cookie | path | query.

path/0

-type path() :: binary().

ref/0

-type ref() :: binary().

request/0

-type request() :: #{body := body()}.

response/0

-type response() :: #{body := body()}.

schema/0

-type schema() :: ndto:schema().

status_code/0

-type status_code() :: 100..599.

Callbacks

parse/1

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

Functions

parse(SpecPath, SpecParser)

-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.