Skip to main content

Header

Struct Header 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Source

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();
Source

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)),
);
Source

pub fn schema<I: Into<RefOr<Schema>>>(self, component: I) -> Self

Add schema of header.

Source

pub fn description<S: Into<String>>(self, description: S) -> Self

Add additional description for header.

Source

pub fn required(self, required: bool) -> Self

Declare whether the header is mandatory.

Source

pub fn deprecated<D: Into<Deprecated>>(self, deprecated: D) -> Self

Declare the header deprecated.

Source

pub fn style(self, style: ParameterStyle) -> Self

Set the serialization style of the header. Only ParameterStyle::Simple is legal.

Source

pub fn explode(self, explode: bool) -> Self

Define whether array or object header values are exploded.

Source

pub fn example(self, example: Value) -> Self

Add an example of the header’s potential value.

Source

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.

Source

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.

Source

pub fn add_extension<K: Into<String>>(self, key: K, value: Value) -> Self

Add openapi extension (x-something) for Header.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Header

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Header

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Header) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Header

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more