PhoenixSwagger.swagger_schema
You're seeing just the macro
swagger_schema
, go back to PhoenixSwagger module for more information.
Builds a swagger schema map using a DSL from the functions defined in PhoenixSwagger.Schema
.
Example
iex> use PhoenixSwagger
...> swagger_schema do
...> title "Pet"
...> description "A pet in the pet store"
...> properties do
...> id :integer, "Unique identifier", required: true, format: :int64
...> name :string, "Pets name", required: true
...> tags array(:string), "Tag categories for this pet"
...> end
...> additional_properties false
...> end
%{
"title" => "Pet",
"type" => "object",
"description" => "A pet in the pet store",
"properties" => %{
"id" => %{
"description" => "Unique identifier",
"format" => "int64",
"type" => "integer"
},
"name" => %{
"description" => "Pets name",
"type" => "string"
},
"tags" => %{
"description" => "Tag categories for this pet",
"items" => %{
"type" => "string"
},
"type" => "array"
}
},
"required" => ["name", "id"],
"additionalProperties" => false
}
iex> use PhoenixSwagger
...> swagger_schema do
...> title "Phone"
...> description "An 8 digit phone number with optional 2 digit area code"
...> type :string
...> max_length 11
...> pattern ~S"^(([0-9]{2}))?[0-9]{4}-[0-9]{4}$"
...> end
%{
"description" => "An 8 digit phone number with optional 2 digit area code",
"maxLength" => 11,
"pattern" => "^(\([0-9]{2}\))?[0-9]{4}-[0-9]{4}$",
"title" => "Phone",
"type" => "string"
}