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: StringThe name of the parameter, case-sensitive.
For ParameterIn::Path this must correspond to exactly one template
expression in the path.
location: ParameterInWhere 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: ExtensionsSpecification extensions.
Implementations§
Source§impl Parameter
impl Parameter
Sourcepub fn new(
name: impl Into<String>,
location: ParameterIn,
schema: Schema,
) -> Self
pub fn new( name: impl Into<String>, location: ParameterIn, schema: Schema, ) -> Self
Creates a schema-described parameter.
Sourcepub fn with_content(
name: impl Into<String>,
location: ParameterIn,
media_type: impl Into<String>,
value: MediaType,
) -> Self
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.
Sourcepub fn path(name: impl Into<String>, schema: Schema) -> Self
pub fn path(name: impl Into<String>, schema: Schema) -> Self
Creates a required path parameter.
Creates a cookie parameter.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Sets the description.
Sourcepub fn with_style(self, style: Style, explode: bool) -> Self
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.
Sourcepub fn with_example(self, value: impl Into<Value>) -> Self
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.
Sourcepub fn with_named_example(
self,
name: impl Into<String>,
example: Example,
) -> Self
pub fn with_named_example( self, name: impl Into<String>, example: Example, ) -> Self
Adds a named example, replacing any inline one.
Sourcepub fn with_named_example_ref(
self,
name: impl Into<String>,
example: Ref,
) -> Self
pub fn with_named_example_ref( self, name: impl Into<String>, example: Ref, ) -> Self
Adds a named example held in
Components::examples.
Sourcepub fn shape(&self) -> &ParameterShape
pub fn shape(&self) -> &ParameterShape
How this parameter’s value is described.
Sourcepub fn shape_mut(&mut self) -> &mut ParameterShape
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.
Sourcepub fn content(&self) -> Option<(&str, &MediaType)>
pub fn content(&self) -> Option<(&str, &MediaType)>
The media type and its description, when this parameter uses content.
Sourcepub fn style(&self) -> Option<Style>
pub fn style(&self) -> Option<Style>
The declared style, if any. Always None for a content-described
parameter.
Sourcepub fn allow_reserved(&self) -> Option<bool>
pub fn allow_reserved(&self) -> Option<bool>
Whether reserved URI characters may appear unencoded.
Sourcepub fn examples(&self) -> Option<&Examples>
pub fn examples(&self) -> Option<&Examples>
The examples this parameter carries, if it carries any.
Sourcepub fn named_examples(&self) -> Option<&Map<RefOr<Example>>>
pub fn named_examples(&self) -> Option<&Map<RefOr<Example>>>
The named examples, when the value is shown with those.
Sourcepub fn effective_style(&self) -> Option<Style>
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.
Sourcepub fn effective_explode(&self) -> Option<bool>
pub fn effective_explode(&self) -> Option<bool>
Returns the effective explode flag, falling back to the style’s default.