Apicult.Parser (Apicult v0.2.0) View Source

Apicult definition parsing

Link to this section Summary

Types

A full parsed apicult definition

A http request body

A key-value pair in a http body

A http body type

A config in the prelude, of the form api_key or api_key=something

An endpoint

An expectation is a list on line that needs to appear in the resulting request. Used for testing an implementation of Apicult.

A key-value pair in a http header

A string containing interpolated variable (eg https://example.com/$api_key/something)

An http method

A key-value pair in a querystring

The type of a variable. For now everything is a :string

An url definition, including method, querystring, headers and body

Functions

Parse the input (an Enum of strings) as an api definition

Parse a file as an api definition

Link to this section Types

Specs

api() :: {:api, prelude :: [config()], endpoints :: [endpoint()]}

A full parsed apicult definition

Specs

body() :: {type :: bodytype(), content :: [bodycontent()]} | nil

A http request body

Specs

bodycontent() :: {String.t(), interpolated()}

A key-value pair in a http body

Specs

bodytype() :: :form | :json

A http body type

Specs

config() :: {:config, name :: atom(), type :: type(), default :: String.t()}

A config in the prelude, of the form api_key or api_key=something

Specs

endpoint() ::
  {:endpoint, name :: String.t(), variables :: [config()], url :: url(),
   result :: Apicult.Result.result() | nil, expectation :: expectation() | nil}

An endpoint

Specs

expectation() :: [String.t()]

An expectation is a list on line that needs to appear in the resulting request. Used for testing an implementation of Apicult.

Specs

http_header() :: {String.t(), interpolated()}

A key-value pair in a http header

Specs

interpolated() :: [string: String.t(), var: atom()]

A string containing interpolated variable (eg https://example.com/$api_key/something)

Specs

method() :: :get | :post

An http method

Specs

querystring() :: {String.t(), interpolated()}

A key-value pair in a querystring

Specs

type() :: :string

The type of a variable. For now everything is a :string

Specs

url() ::
  {:url, method :: method(), url :: interpolated(),
   querystring :: [querystring()], headers :: [http_header()], body :: body()}

An url definition, including method, querystring, headers and body

Link to this section Functions

Specs

parse(Enum.t()) :: {:ok, api()}

Parse the input (an Enum of strings) as an api definition

Specs

parse_file(binary()) :: {:ok, api()}

Parse a file as an api definition

Specs

parse_url(String.t()) :: url()