plumbapius v0.13.0 Plumbapius.Request.Schema

Describes the request schema for validation

Link to this section Summary

Types

t()

Request Schema

Functions

Returns a request schema created from a tomogram.

Link to this section Types

Specs

t() :: %Plumbapius.Request.Schema{
  body: ExJsonSchema.Schema.Root.t(),
  content_type: Regex.t() | String.t() | :any_content_type,
  method: String.t(),
  original_path: String.t(),
  path: Regex.t(),
  responses: [Plumbapius.Response.Schema.t()]
}

Request Schema

Link to this section Functions

Specs

new(map()) :: t()

Returns a request schema created from a tomogram.

Parameters

  • tomogram: Description of the request schema as a hash.

Examples

iex> Plumbapius.Request.Schema.new(%{
...>   "method"=>"GET",
...>   "path"=>"/users/{id}",
...>   "content-type"=>"multipart/mixed; boundary={boundary}",
...>   "request"=>%{
...>     "$schema" => "http://json-schema.org/draft-04/schema#",
...>     "type" => "object",
...>     "properties" => %{"msisdn" => %{"type" => "number"}},
...>     "required" => ["msisdn"]
...>   },
...>   "responses"=>[]
...> })
%Plumbapius.Request.Schema{
  method: "GET",
  original_path: "/users/{id}",
  path: ~r/\A\/users\/[^&=\/]+\z/,
  content_type: ~r/\Amultipart\/mixed; boundary=[^\s]+\z/,
  body: %ExJsonSchema.Schema.Root{
    custom_format_validator: nil,
    location: :root,
    refs: %{},
    schema: %{
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "type" => "object",
      "properties" => %{"msisdn" => %{"type" => "number"}},
      "required" => ["msisdn"]
    }
  },
  responses: []
}