A path parameter definition with explicit serialization settings.
Tesla.OpenAPI.PathParam is a value object for path parameter metadata whose
serialization needs to be controlled explicitly. Its serialization options
follow the OpenAPI path parameter style semantics.
In Tesla.Middleware.PathParams :modern mode, define path parameters once
and pass them through Tesla.Env.private/0 with Tesla.OpenAPI.PathParams:
path_params = Tesla.OpenAPI.PathParams.new!([PathParam.new!("id")])
private = Tesla.OpenAPI.PathParams.put_private(path_params)
Tesla.get(client, "/items/{id}",
opts: [path_params: %{"id" => 42}],
private: private
)Pass options when a value needs non-default path serialization:
alias Tesla.OpenAPI.PathParam
Tesla.OpenAPI.PathParams.new!([
PathParam.new!("coords", style: :matrix, explode: true)
])Encoding
Tesla.Middleware.PathParams serializes values using the
OpenAPI path parameter rules for the simple, matrix, and
label styles. Serialized values are percent-encoded against the RFC 3986
unreserved set (A-Z, a-z, 0-9, -, _, ., ~); spaces become
%20 (not +).
With allow_reserved: true, path-safe reserved characters are preserved, but
characters that would change the URL path shape, such as /, ?, or #,
are still percent-encoded.
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.
Missing And Empty Values
nil values and missing path parameters are handled by
Tesla.Middleware.PathParams, which leaves unmatched placeholders untouched.
Empty arrays and empty objects serialize according to the OpenAPI
"undefined" column for the selected style.
Summary
Functions
Creates a path parameter definition.
Types
Functions
Creates a path parameter definition.
Options use Elixir atoms for hand-written Tesla code:
:style— one of:simple,:matrix,:label. Defaults to:simple.:explode— boolean. Defaults tofalse.:allow_reserved— boolean. Defaults tofalse.