#[non_exhaustive]pub struct Encoding {
pub content_type: Option<String>,
pub headers: PropMap<String, Header>,
pub style: Option<ParameterStyle>,
pub explode: Option<bool>,
pub allow_reserved: Option<bool>,
pub encoding: PropMap<String, Encoding>,
pub prefix_encoding: Vec<Encoding>,
pub item_encoding: Option<Box<Encoding>>,
pub extensions: PropMap<String, Value>,
}Expand description
A single encoding definition applied to a single schema Object property.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.content_type: Option<String>The Content-Type for encoding a specific property. Default value depends on the property
type: for string with format being binary – application/octet-stream; for other primitive
types – text/plain; for object - application/json; for array – the default is defined
based on the inner type. The value can be a specific media type (e.g. application/json),
a wildcard media type (e.g. image/*), or a comma-separated list of the two types.
headers: PropMap<String, Header>A map allowing additional information to be provided as headers, for example Content-Disposition. Content-Type is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a multipart.
style: Option<ParameterStyle>Describes how a specific property value will be serialized depending on its type. See
Parameter Object for details on the style property. The behavior follows the same values as
query parameters, including default values. This property SHALL be ignored if the request
body media type is not application/x-www-form-urlencoded.
explode: Option<bool>When this is true, property values of type array or object generate separate parameters for
each value of the array, or key-value-pair of the map. For other types of properties this
property has no effect. When style is form, the default value is true. For all other
styles, the default value is false. This property SHALL be ignored if the request body
media type is not application/x-www-form-urlencoded.
allow_reserved: Option<bool>When this is true, values are serialized using reserved expansion, letting RFC3986’s
reserved character set :/?#[]@!$&'()*+,;= pass through unchanged. The default value is
false.
In OpenAPI 3.1 this only applied to application/x-www-form-urlencoded request bodies;
OpenAPI 3.2 generalizes it to RFC6570-style serialization, and it has no effect for
multipart/form-data.
encoding: PropMap<String, Encoding>Nested encoding applied by property name, mirroring the Content::encoding field of the
enclosing media type. Added in OpenAPI 3.2.
Must not be combined with Encoding::prefix_encoding or Encoding::item_encoding.
prefix_encoding: Vec<Encoding>Nested positional encoding, mirroring the Content::prefix_encoding field of the
enclosing media type. Added in OpenAPI 3.2.
item_encoding: Option<Box<Encoding>>Nested encoding applied to every remaining array item, mirroring the
Content::item_encoding field of the enclosing media type. Added in OpenAPI 3.2.
extensions: PropMap<String, Value>Optional extensions “x-something”
Implementations§
Source§impl Encoding
impl Encoding
Sourcepub fn content_type<S: Into<String>>(self, content_type: S) -> Self
pub fn content_type<S: Into<String>>(self, content_type: S) -> Self
Set the content type. See Encoding::content_type.
Sourcepub fn header<S: Into<String>, H: Into<Header>>(
self,
header_name: S,
header: H,
) -> Self
pub fn header<S: Into<String>, H: Into<Header>>( self, header_name: S, header: H, ) -> Self
Add a Header. See Encoding::headers.
Sourcepub fn style(self, style: ParameterStyle) -> Self
pub fn style(self, style: ParameterStyle) -> Self
Set the style ParameterStyle. See Encoding::style.
Sourcepub fn explode(self, explode: bool) -> Self
pub fn explode(self, explode: bool) -> Self
Set the explode. See Encoding::explode.
Sourcepub fn allow_reserved(self, allow_reserved: bool) -> Self
pub fn allow_reserved(self, allow_reserved: bool) -> Self
Set the allow reserved. See Encoding::allow_reserved.
Sourcepub fn encoding<S: Into<String>, E: Into<Self>>(
self,
property_name: S,
encoding: E,
) -> Self
pub fn encoding<S: Into<String>, E: Into<Self>>( self, property_name: S, encoding: E, ) -> Self
Add a nested Encoding by property name. See Encoding::encoding.
Requires OpenAPI 3.2.
Sourcepub fn prefix_encoding<I: IntoIterator<Item = Self>>(
self,
prefix_encoding: I,
) -> Self
pub fn prefix_encoding<I: IntoIterator<Item = Self>>( self, prefix_encoding: I, ) -> Self
Set the nested positional encodings. See Encoding::prefix_encoding.
Requires OpenAPI 3.2.
Sourcepub fn item_encoding<E: Into<Self>>(self, item_encoding: E) -> Self
pub fn item_encoding<E: Into<Self>>(self, item_encoding: E) -> Self
Set the nested encoding applied to remaining array items. See Encoding::item_encoding.
Requires OpenAPI 3.2.