openapiv3/
media_type.rs

1use crate::*;
2use indexmap::IndexMap;
3use serde::{Deserialize, Serialize};
4
5/// Each Media Type Object provides schema and examples for the media type
6/// identified by its key.
7#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
8pub struct MediaType {
9    /// The schema defining the content of the request, response, or parameter.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub schema: Option<ReferenceOr<Schema>>,
12    /// Example of the media type. The example object SHOULD be in the correct
13    /// format as specified by the media type. The example field is mutually
14    /// exclusive of the examples field. Furthermore, if referencing a schema
15    /// which contains an example, the example value SHALL override the example
16    /// provided by the schema.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub example: Option<serde_json::Value>,
19    /// Examples of the media type. Each example object SHOULD match the media
20    /// type and specified schema if present. The examples field is mutually
21    /// exclusive of the example field. Furthermore, if referencing a schema
22    /// which contains an example, the examples value SHALL override the
23    /// example provided by the schema.
24    #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
25    pub examples: IndexMap<String, ReferenceOr<Example>>,
26    /// A map between a property name and its encoding information. The key,
27    /// being the property name, MUST exist in the schema as a property. The
28    /// encoding object SHALL only apply to requestBody objects when the media
29    /// type is multipart or application/x-www-form-urlencoded.
30    #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
31    pub encoding: IndexMap<String, Encoding>,
32
33    /// Inline extensions to this object.
34    #[serde(flatten, deserialize_with = "crate::util::deserialize_extensions")]
35    pub extensions: IndexMap<String, serde_json::Value>,
36}