View Source Swagdox.Response (swagdox v0.2.0)

Describes a response in an OpenAPI specification.

Summary

Types

@type t() :: %Swagdox.Response{
  content: map() | nil,
  description: String.t(),
  options: term(),
  status: integer()
}

Functions

Link to this function

build(status, description)

View Source
@spec build(integer(), String.t()) :: t()
Link to this function

build(status, description, options)

View Source
@spec build(integer(), String.t(), keyword()) :: t()
@spec build(integer(), String.t(), String.t()) :: t()
Link to this function

build(status, schema, description, options)

View Source
@spec build(integer(), String.t() | nil, String.t(), keyword()) :: t()
@spec render(t()) :: map()

Renders a response to a map.

Examples

iex> response = Response.build(200, "User", "OK")
iex> Response.render(response)
%{
  "200" => %{
    "description" => "OK",
    "content" => %{
      "application/json" => %{
        "schema" => %{
          "$ref" => "#/components/schemas/User"
        }
      }
    }
  }
}

iex> response = Response.build(200, "OK")
iex> Response.render(response)
%{
  "200" => %{
    "description" => "OK"
  }
}