#[non_exhaustive]pub struct Parameter {Show 13 fields
pub name: String,
pub parameter_in: ParameterIn,
pub description: Option<String>,
pub required: Required,
pub deprecated: Option<Deprecated>,
pub allow_empty_value: Option<bool>,
pub schema: Option<RefOr<Schema>>,
pub style: Option<ParameterStyle>,
pub explode: Option<bool>,
pub allow_reserved: Option<bool>,
pub examples: PropMap<String, RefOr<Example>>,
pub content: PropMap<String, Content>,
pub extensions: PropMap<String, Value>,
/* private fields */
}Expand description
Implements OpenAPI Parameter Object for Operation.
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.name: StringName of the parameter.
- For
ParameterIn::Paththis must in accordance to path templating. - For
ParameterIn::QueryContent-TypeorAuthorizationvalue will be ignored.
parameter_in: ParameterInParameter location.
description: Option<String>Markdown supported description of the parameter.
required: RequiredDeclares whether the parameter is required or not for api.
- For
ParameterIn::Paththis must and will beRequired::True. - Defaults to
Required::Unset, which is omitted from the serialized output.
deprecated: Option<Deprecated>Declares the parameter deprecated status.
allow_empty_value: Option<bool>Sets the ability to pass empty-valued parameters. Only applicable to
ParameterIn::Query parameters. Defaults to false.
Note: per the OpenAPI 3.1 spec the use of this property is discouraged and may be removed in a future version.
schema: Option<RefOr<Schema>>Schema of the parameter. Typically Schema::Object is used.
Mutually exclusive with Parameter::content; per the spec a parameter must
describe its value with one or the other, not both.
style: Option<ParameterStyle>Describes how Parameter is being serialized depending on Parameter::schema (type of
a content). Default value is based on ParameterIn.
explode: Option<bool>When true it will generate separate parameter value for each parameter with array
and object type. This is also true by default for ParameterStyle::Form.
With explode false:
color=blue,black,brownWith explode true:
color=blue&color=black&color=brownallow_reserved: Option<bool>Defines whether parameter should allow reserved characters defined by
RFC3986 :/?#[]@!$&'()*+,;=.
This is only applicable with ParameterIn::Query. Default value is false.
examples: PropMap<String, RefOr<Example>>Examples of the parameter’s potential value, indexed by name. When both
Parameter::example and examples are present, examples takes precedence.
content: PropMap<String, Content>A map containing the representations for the parameter, keyed by media type.
Per the OpenAPI 3.1 spec the map must contain exactly one entry. Mutually exclusive
with Parameter::schema.
extensions: PropMap<String, Value>Optional extensions “x-something”
Implementations§
Source§impl Parameter
impl Parameter
Sourcepub fn new<S: Into<String>>(name: S) -> Self
pub fn new<S: Into<String>>(name: S) -> Self
Constructs a new required Parameter with given name.
Sourcepub fn location(self, location: ParameterIn) -> Self
pub fn location(self, location: ParameterIn) -> Self
Sets the location (in) of the Parameter.
If the location is ParameterIn::Path, the parameter is also marked required.
Sourcepub fn parameter_in(self, parameter_in: ParameterIn) -> Self
👎Deprecated since 0.94.0: use Parameter::location instead
pub fn parameter_in(self, parameter_in: ParameterIn) -> Self
use Parameter::location instead
Sets the location (in) of the Parameter.
Sourcepub fn required(self, required: impl Into<Required>) -> Self
pub fn required(self, required: impl Into<Required>) -> Self
Add required declaration of the Parameter. If ParameterIn::Path is
defined this is always Required::True.
Sourcepub fn description<S: Into<String>>(self, description: S) -> Self
pub fn description<S: Into<String>>(self, description: S) -> Self
Add or change description of the Parameter.
Sourcepub fn deprecated<D: Into<Deprecated>>(self, deprecated: D) -> Self
pub fn deprecated<D: Into<Deprecated>>(self, deprecated: D) -> Self
Add or change Parameter deprecated declaration.
Sourcepub fn schema<I: Into<RefOr<Schema>>>(self, component: I) -> Self
pub fn schema<I: Into<RefOr<Schema>>>(self, component: I) -> Self
Add or change Parameters schema.
Sourcepub fn style(self, style: ParameterStyle) -> Self
pub fn style(self, style: ParameterStyle) -> Self
Add or change serialization style of Parameter.
Sourcepub fn allow_reserved(self, allow_reserved: bool) -> Self
pub fn allow_reserved(self, allow_reserved: bool) -> Self
Add or change whether Parameter should allow reserved characters.
Sourcepub fn example(self, example: Value) -> Self
pub fn example(self, example: Value) -> Self
Add or change example of Parameter’s potential value.
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 Parameter::examples.
When set, examples takes precedence over Parameter::example.
Sourcepub fn examples<I, N, E>(self, examples: I) -> Self
pub fn examples<I, N, E>(self, examples: I) -> Self
Replace Parameter::examples with the contents of an iterator of named 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 Parameter::content.
Per spec the content map must contain exactly one entry. Mutually exclusive with
Parameter::schema.
Sourcepub fn allow_empty_value(self, allow: bool) -> Self
pub fn allow_empty_value(self, allow: bool) -> Self
Allow or disallow empty-valued query parameters.
Note: per the OpenAPI 3.1 spec the use of this property is discouraged.