open_api_spex v3.4.0 OpenApiSpex.Parameter View Source

Defines the OpenApiSpex.Parameter.t type.

Link to this section Summary

Types

Valid values for the in key in the OpenApiSpex.Parameter struct

Valid values for the style key in the OpenApiSpex.Parameter struct

Functions

Sets the schema for a parameter from a simple type, reference or Schema

Gets the schema for a parameter, from the schema key or content key, which ever is populated

Link to this section Types

Link to this type

location() View Source
location() :: :path | :query | :header | :cookie

Valid values for the in key in the OpenApiSpex.Parameter struct.

Link to this type

style() View Source
style() ::
  :matrix
  | :label
  | :form
  | :simple
  | :spaceDelimited
  | :pipeDelimited
  | :deepObject

Valid values for the style key in the OpenApiSpex.Parameter struct.

Link to this type

t() View Source
t() :: %OpenApiSpex.Parameter{
  allowEmptyValue: boolean() | nil,
  allowReserved: boolean() | nil,
  content: %{optional(String.t()) => OpenApiSpex.MediaType.t()} | nil,
  deprecated: boolean() | nil,
  description: String.t() | nil,
  example: any(),
  examples:
    %{
      optional(String.t()) =>
        OpenApiSpex.Example.t() | OpenApiSpex.Reference.t()
    }
    | nil,
  explode: boolean() | nil,
  in: location(),
  name: atom(),
  required: boolean() | nil,
  schema: OpenApiSpex.Schema.t() | OpenApiSpex.Reference.t() | atom() | nil,
  style: style() | nil
}

Parameter Object

Describes a single operation parameter.

A unique parameter is defined by a combination of a name and location.

Parameter Locations

There are four possible parameter locations specified by the in field:

  • path: Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in /items/{itemId}, the path parameter is itemId.
  • query: Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.
  • header: Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
  • cookie: Used to pass a specific cookie value to the API.

Link to this section Functions

Link to this function

put_schema(parameter, type) View Source
put_schema(t(), OpenApiSpex.Reference.t() | OpenApiSpex.Schema.t() | atom()) ::
  t()

Sets the schema for a parameter from a simple type, reference or Schema

Gets the schema for a parameter, from the schema key or content key, which ever is populated.