openapiv3/
encoding.rs

1use crate::*;
2use indexmap::IndexMap;
3use serde::{Deserialize, Serialize};
4
5/// A single encoding definition applied to a single schema property.
6#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
7#[serde(rename_all = "camelCase")]
8pub struct Encoding {
9    /// The Content-Type for encoding a specific property.
10    /// Default value depends on the property type: for string
11    /// with format being binary – application/octet-stream;
12    /// for other primitive types – text/plain;
13    /// for object - application/json;
14    /// for array – the default is defined based on the inner type.
15    /// The value can be a specific media type (e.g. application/json),
16    /// a wildcard media type (e.g. image/*), or a comma-separated list of the two types.
17    pub content_type: Option<String>,
18    /// A map allowing additional information to be provided as headers,
19    /// for example Content-Disposition. Content-Type is described separately
20    /// and SHALL be ignored in this section. This property SHALL be ignored
21    /// if the request body media type is not a multipart.
22    #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
23    pub headers: IndexMap<String, RefOr<Header>>,
24    /// Describes how a specific property value will be serialized depending
25    /// on its type. See Parameter Object for details on the style property.
26    /// The behavior follows the same values as query parameters, including
27    /// default values. This property SHALL be ignored if the request body
28    /// media type is not application/x-www-form-urlencoded.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub style: Option<QueryStyle>,
31    /// When this is true, property values of type array or object generate
32    /// separate parameters for each value of the array, or key-value-pair
33    /// of the map. For other types of properties this property has no effect.
34    /// When style is form, the default value is true.
35    /// For all other styles, the default value is false. This property
36    /// SHALL be ignored if the request body media type is
37    /// not application/x-www-form-urlencoded.
38    ///
39    /// In this Library this value defaults to false always despite the specification.
40    #[serde(default, skip_serializing_if = "is_false")]
41    pub explode: bool,
42    /// Determines whether the parameter value SHOULD allow reserved characters,
43    /// as defined by RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding.
44    /// The default value is false. This property SHALL be ignored if the request
45    /// body media type is not application/x-www-form-urlencoded.
46    #[serde(default, skip_serializing_if = "is_false")]
47    pub allow_reserved: bool,
48    /// Inline extensions to this object.
49    #[serde(flatten, deserialize_with = "crate::util::deserialize_extensions")]
50    pub extensions: IndexMap<String, serde_json::Value>,
51}