#[non_exhaustive]pub struct Header {
pub description: Option<String>,
pub required: Option<bool>,
pub deprecated: Option<Deprecated>,
pub schema: Option<RefOr<Schema>>,
pub style: Option<ParameterStyle>,
pub explode: Option<bool>,
pub example: Option<Value>,
pub examples: PropMap<String, RefOr<Example>>,
pub content: PropMap<String, Content>,
pub extensions: PropMap<String, Value>,
}Expand description
Implements OpenAPI Header Object for response headers and for individual parts in
multipart representations.
A Header Object follows the structure of the Parameter object minus
name and in, and describes its value either through Header::schema or through
Header::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.description: Option<String>Additional description of the header value.
required: Option<bool>Determines whether this header is mandatory. Defaults to false.
deprecated: Option<Deprecated>Declares the header deprecated and to be transitioned out of usage.
schema: Option<RefOr<Schema>>Schema of header type. Mutually exclusive with Header::content.
style: Option<ParameterStyle>Describes how the header value is serialized. The only legal value for headers is
ParameterStyle::Simple, which is also the default.
explode: Option<bool>When true, array or object header values generate a single header whose value is a
comma-separated list. Defaults to false.
example: Option<Value>Example of the header’s potential value.
examples: PropMap<String, RefOr<Example>>Examples of the header’s potential value, indexed by name. Mutually exclusive with
Header::example.
content: PropMap<String, Content>A map containing the representations for the header, keyed by media type. Per spec the
map must contain exactly one entry. Mutually exclusive with Header::schema.
extensions: PropMap<String, Value>Optional extensions “x-something”
Implementations§
Source§impl Header
impl Header
Sourcepub fn new<C: Into<RefOr<Schema>>>(component: C) -> Self
pub fn new<C: Into<RefOr<Schema>>>(component: C) -> Self
Construct a new Header with custom schema. If you wish to construct a default
header with String type you can use Header::default function.
§Examples
Creates a new Header with an integer type.
let header = Header::new(Object::with_type(BasicType::Integer));Create a new Header with default type String
let header = Header::default();Sourcepub fn with_content<S: Into<String>, C: Into<Content>>(
media_type: S,
content: C,
) -> Self
pub fn with_content<S: Into<String>, C: Into<Content>>( media_type: S, content: C, ) -> Self
Construct a Header that describes its value with a media type instead of a schema.
let header = Header::with_content(
"application/linkset",
Content::new(Object::with_type(BasicType::String)),
);Sourcepub fn description<S: Into<String>>(self, description: S) -> Self
pub fn description<S: Into<String>>(self, description: S) -> Self
Add additional description for header.
Sourcepub fn deprecated<D: Into<Deprecated>>(self, deprecated: D) -> Self
pub fn deprecated<D: Into<Deprecated>>(self, deprecated: D) -> Self
Declare the header deprecated.
Sourcepub fn style(self, style: ParameterStyle) -> Self
pub fn style(self, style: ParameterStyle) -> Self
Set the serialization style of the header. Only ParameterStyle::Simple is legal.
Sourcepub fn explode(self, explode: bool) -> Self
pub fn explode(self, explode: bool) -> Self
Define whether array or object header values are exploded.
Sourcepub fn add_example<N: Into<String>, E: Into<RefOr<Example>>>(
self,
name: N,
example: E,
) -> Self
pub fn add_example<N: Into<String>, E: Into<RefOr<Example>>>( self, name: N, example: E, ) -> Self
Insert a named Example (or a Ref to one) into Header::examples.
Sourcepub fn content<S: Into<String>, C: Into<Content>>(
self,
media_type: S,
content: C,
) -> Self
pub fn content<S: Into<String>, C: Into<Content>>( self, media_type: S, content: C, ) -> Self
Insert a single media-type entry into Header::content.
Per spec the content map must contain exactly one entry. Mutually exclusive with
Header::schema.