Skip to main content

Parameter

Struct Parameter 

Source
pub struct Parameter {
    pub name: String,
    pub location: ParameterIn,
    pub description: Option<String>,
    pub required: Option<bool>,
    pub deprecated: Option<bool>,
    pub allow_empty_value: Option<bool>,
    pub extensions: Extensions,
    /* private fields */
}
Expand description

A single operation parameter.

The value is described by a ParameterShape, which is one of schema or content and never both or neither, and shown by an Examples, which is the inline example or the named examples and never both.

Fields§

§name: String

The name of the parameter, case-sensitive.

For ParameterIn::Path this must correspond to exactly one template expression in the path.

§location: ParameterIn

Where the parameter is carried.

§description: Option<String>

A description of the parameter. CommonMark syntax may be used.

§required: Option<bool>

Whether the parameter is mandatory.

Must be true when location is ParameterIn::Path.

§deprecated: Option<bool>

Whether the parameter is deprecated.

§allow_empty_value: Option<bool>

Whether an empty value is permitted. Query parameters only.

Not recommended in 3.1, and formally deprecated in 3.2.

§extensions: Extensions

Specification extensions.

Implementations§

Source§

impl Parameter

Source

pub fn new( name: impl Into<String>, location: ParameterIn, schema: Schema, ) -> Self

Creates a schema-described parameter.

Source

pub fn with_content( name: impl Into<String>, location: ParameterIn, media_type: impl Into<String>, value: MediaType, ) -> Self

Creates a parameter described by one media type.

For the values a sequence of style rules cannot express — JSON in a query string, a nested filter.

Source

pub fn path(name: impl Into<String>, schema: Schema) -> Self

Creates a required path parameter.

Source

pub fn query(name: impl Into<String>, schema: Schema) -> Self

Creates a query parameter.

Source

pub fn header(name: impl Into<String>, schema: Schema) -> Self

Creates a header parameter.

Source

pub fn cookie(name: impl Into<String>, schema: Schema) -> Self

Creates a cookie parameter.

Source

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

Marks the parameter mandatory.

Source

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

Sets the description.

Source

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

Sets the serialization style and explode flag.

A no-op on a content-described parameter, which has no style to set.

Source

pub fn with_example(self, value: impl Into<Value>) -> Self

Shows the value with one inline example.

Replaces any named examples: the two forms exclude each other, so there is no state that holds both.

Source

pub fn with_named_example( self, name: impl Into<String>, example: Example, ) -> Self

Adds a named example, replacing any inline one.

Source

pub fn with_named_example_ref( self, name: impl Into<String>, example: Ref, ) -> Self

Adds a named example held in Components::examples.

Source

pub fn shape(&self) -> &ParameterShape

How this parameter’s value is described.

Source

pub fn shape_mut(&mut self) -> &mut ParameterShape

The same, mutably.

Handing out &mut costs nothing here: every ParameterShape is a valid description, so there is no combination a caller could reach by editing one that it could not reach by building one.

Source

pub fn schema(&self) -> Option<&Schema>

The schema, when this parameter is described by one.

Source

pub fn content(&self) -> Option<(&str, &MediaType)>

The media type and its description, when this parameter uses content.

Source

pub fn style(&self) -> Option<Style>

The declared style, if any. Always None for a content-described parameter.

Source

pub fn allow_reserved(&self) -> Option<bool>

Whether reserved URI characters may appear unencoded.

Source

pub fn examples(&self) -> Option<&Examples>

The examples this parameter carries, if it carries any.

Source

pub fn example(&self) -> Option<&Value>

The inline example, when the value is shown with one.

Source

pub fn named_examples(&self) -> Option<&Map<RefOr<Example>>>

The named examples, when the value is shown with those.

Source

pub fn effective_style(&self) -> Option<Style>

Returns the effective style, falling back to the location’s default.

None for a content-described parameter: style does not apply to one, so there is no default to fall back to either.

Source

pub fn effective_explode(&self) -> Option<bool>

Returns the effective explode flag, falling back to the style’s default.

Trait Implementations§

Source§

impl Clone for Parameter

Source§

fn clone(&self) -> Self

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 Parameter

Source§

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

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

impl<'de> Deserialize<'de> for Parameter

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 Parameter

Source§

fn eq(&self, other: &Self) -> 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 Parameter

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 Parameter

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<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, 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> 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, !>

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.