#[non_exhaustive]pub struct Content {
pub ref_location: Option<String>,
pub schema: Option<RefOr<Schema>>,
pub item_schema: Option<RefOr<Schema>>,
pub example: Option<Value>,
pub examples: PropMap<String, RefOr<Example>>,
pub encoding: PropMap<String, Encoding>,
pub prefix_encoding: Vec<Encoding>,
pub item_encoding: Option<Encoding>,
pub extensions: PropMap<String, Value>,
}Expand description
Content holds request body content or response content.
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.ref_location: Option<String>Reference to a reusable Media Type Object, e.g. one defined under
components.mediaTypes. Added in OpenAPI 3.2.
content maps are typed as Content rather than RefOr<Content> so that existing
callers keep compiling; a Content carrying only this field serializes exactly as a
Reference Object. As with any Reference Object, sibling fields are ignored by consumers.
let content = Content::from_ref("#/components/mediaTypes/FramePayload");schema: Option<RefOr<Schema>>Schema used in response body or request body.
item_schema: Option<RefOr<Schema>>Schema describing each item within a sequential media type, e.g. text/event-stream or
application/jsonl. Added in OpenAPI 3.2.
Unlike Content::schema, which applies to the complete content, item_schema applies
to each item in the stream independently. Both may be used together.
See https://spec.openapis.org/oas/v3.2.0.html#media-type-object.
example: Option<Value>Example for request body or response body.
examples: PropMap<String, RefOr<Example>>Examples of the request body or response body. Content::examples should match to
media type and specified schema if present. Content::examples and
Content::example are mutually exclusive. If both are defined examples will
override value in example.
encoding: PropMap<String, Encoding>A map between a property name and its encoding information.
The key, being the property name, MUST exist in the Content::schema as a property, with
schema being a Schema::Object and this object containing the same property key in
Object::properties.
The encoding object SHALL only apply to request_body objects when the media type is
multipart or application/x-www-form-urlencoded.
Must not be combined with Content::prefix_encoding or Content::item_encoding.
prefix_encoding: Vec<Encoding>Positional encoding information, applied to the array item at the same index. Added in
OpenAPI 3.2 and only applicable to multipart media types.
Requires either Content::item_schema or an array Content::schema to be present,
and must not be combined with Content::encoding.
item_encoding: Option<Encoding>A single encoding applied to all array items not covered by
Content::prefix_encoding. Added in OpenAPI 3.2 and only applicable to multipart
media types.
Requires either Content::item_schema or an array Content::schema to be present,
and must not be combined with Content::encoding.
extensions: PropMap<String, Value>Optional extensions “x-something”
Implementations§
Source§impl Content
impl Content
Sourcepub fn from_ref<S: Into<String>>(ref_location: S) -> Self
pub fn from_ref<S: Into<String>>(ref_location: S) -> Self
Construct a Content that is purely a reference to a reusable Media Type Object.
Requires OpenAPI 3.2.
Sourcepub fn ref_location<S: Into<String>>(self, ref_location: S) -> Self
pub fn ref_location<S: Into<String>>(self, ref_location: S) -> Self
Set the $ref location for this Content and return self. Requires OpenAPI 3.2.
Sourcepub fn item_schema<I: Into<RefOr<Schema>>>(self, component: I) -> Self
pub fn item_schema<I: Into<RefOr<Schema>>>(self, component: I) -> Self
Add the schema describing each item of a sequential media type.
See Content::item_schema. Requires OpenAPI 3.2.
Sourcepub fn extend_examples<E: IntoIterator<Item = (N, V)>, N: Into<String>, V: Into<RefOr<Example>>>(
self,
examples: E,
) -> Self
pub fn extend_examples<E: IntoIterator<Item = (N, V)>, N: Into<String>, V: Into<RefOr<Example>>>( self, examples: E, ) -> Self
Add iterator of (N, V) where N is name of example and V is Example to
Content of a request body or response body.
Content::examples and Content::example are mutually exclusive. If both are defined
examples will override value in example.
Sourcepub fn extensions(self, extensions: PropMap<String, Value>) -> Self
pub fn extensions(self, extensions: PropMap<String, Value>) -> Self
Add openapi extensions (x-something) for Content.
Sourcepub fn encoding<S: Into<String>, E: Into<Encoding>>(
self,
property_name: S,
encoding: E,
) -> Self
pub fn encoding<S: Into<String>, E: Into<Encoding>>( self, property_name: S, encoding: E, ) -> Self
Add an encoding.
The property_name MUST exist in the Content::schema as a property,
with schema being a Schema::Object and this object containing the same property
key in Object::properties.
The encoding object SHALL only apply to request_body objects when the media type is
multipart or application/x-www-form-urlencoded.
Sourcepub fn prefix_encoding<I: IntoIterator<Item = Encoding>>(
self,
prefix_encoding: I,
) -> Self
pub fn prefix_encoding<I: IntoIterator<Item = Encoding>>( self, prefix_encoding: I, ) -> Self
Set the positional encodings. See Content::prefix_encoding. Requires OpenAPI 3.2.
Sourcepub fn item_encoding<E: Into<Encoding>>(self, item_encoding: E) -> Self
pub fn item_encoding<E: Into<Encoding>>(self, item_encoding: E) -> Self
Set the encoding applied to remaining array items. See Content::item_encoding.
Requires OpenAPI 3.2.