radex v0.1.0 Radex.Writer.JSON.Example View Source

Generate example files

Link to this section Summary

Functions

Generate an example

Generate a header from a Conn tuple

Generates a map of headers

Generate a single paramter

Generate parameters from the metadata

Generate a single request map from a Radex.Conn

Generate response map from a Radex.Conn

Generate and write the example files

Generate and write a single example file

Link to this section Functions

Link to this function generate_example(example) View Source
generate_example(map) :: String.t

Generate an example

Link to this function generate_header(arg) View Source
generate_header({header :: String.t, value :: String.t}) :: {String.t, String.t}

Generate a header from a Conn tuple

Will properly capitalize the header

Link to this function generate_headers(headers) View Source

Generates a map of headers

iex> Example.generate_headers([{"content-type", "application/json"}, {"accept", "application/json"}])
%{"Content-Type" => "application/json", "Accept" => "application/json"}

Generate a single paramter

iex> Example.generate_parameter({"name", "description"})
%{name: "name", description: "description"}

iex> Example.generate_parameter({"name", "description", extra: :keys})
%{name: "name", description: "description", extra: :keys}
Link to this function generate_parameters(list) View Source

Generate parameters from the metadata

iex> Example.generate_parameters([{"name", "description"}])
[%{name: "name", description: "description"}]
Link to this function generate_request(conn) View Source
generate_request(Radex.Conn.t) :: map

Generate a single request map from a Radex.Conn

Link to this function generate_requests(list) View Source
generate_requests([Radex.Conn.t]) :: [map]

Generate response map from a Radex.Conn

Link to this function write(metadata, path) View Source
write(map, Path.t) :: :ok

Generate and write the example files

Link to this function write_example(example, path) View Source
write_example(map, Path.t) :: :ok

Generate and write a single example file