Tesla.OpenAPI.HeaderParam (tesla v1.18.1)

Copy Markdown View Source

A header parameter with explicit serialization settings.

Tesla.OpenAPI.HeaderParam is a value object for header parameters whose serialization needs to be controlled explicitly. Its serialization options follow the OpenAPI header parameter style semantics.

Define header parameters once and apply them to request values with Tesla.OpenAPI.HeaderParams:

alias Tesla.OpenAPI.{HeaderParam, HeaderParams}

header_params =
  HeaderParams.new!([
    HeaderParam.new!("X-Token")
  ])

HeaderParams.to_headers(header_params, %{"X-Token" => [12345678, 90099]})

Encoding

Tesla.OpenAPI.HeaderParams.to_headers/2 serializes values using the OpenAPI header parameter rules for the simple style. Header values are passed through unchanged after converting each part with to_string/1; URI percent-encoding is not applied.

Object Value Ordering

Object values may be passed as maps, structs, or keyword lists. Keyword lists preserve insertion order; map iteration order is intrinsic and not guaranteed across Elixir versions. Pass an ordered keyword list when the exact serialized order matters.

Summary

Functions

Creates a header parameter definition.

Types

style()

@type style() :: :simple

t()

@opaque t()

Functions

new!(name, opts \\ [])

@spec new!(String.t(), style: style(), explode: boolean()) :: t()

Creates a header parameter definition.

Options use Elixir atoms for hand-written Tesla code:

  • :style - must be :simple. Defaults to :simple.
  • :explode - boolean. Defaults to false.