pub struct ParamMeta {Show 13 fields
pub title: Option<String>,
pub description: Option<String>,
pub deprecated: bool,
pub include_in_schema: bool,
pub example: Option<Value>,
pub examples: HashMap<String, Example>,
pub ge: Option<f64>,
pub le: Option<f64>,
pub gt: Option<f64>,
pub lt: Option<f64>,
pub min_length: Option<usize>,
pub max_length: Option<usize>,
pub pattern: Option<String>,
}Expand description
Parameter metadata for OpenAPI documentation.
This struct captures metadata attributes that can be specified on
struct fields using #[param(...)] attributes.
§Example
ⓘ
#[derive(FromRequest)]
struct MyQuery {
#[param(description = "Search term", deprecated)]
q: Option<String>,
#[param(title = "Page Number", ge = 1)]
page: i32,
}Fields§
§title: Option<String>Display title for the parameter.
description: Option<String>Description of the parameter.
deprecated: boolWhether the parameter is deprecated.
include_in_schema: boolWhether to include in OpenAPI schema.
example: Option<Value>Example value.
examples: HashMap<String, Example>Named examples.
ge: Option<f64>Minimum value constraint (for numbers).
le: Option<f64>Maximum value constraint (for numbers).
gt: Option<f64>Exclusive minimum (for numbers).
lt: Option<f64>Exclusive maximum (for numbers).
min_length: Option<usize>Minimum length (for strings).
max_length: Option<usize>Maximum length (for strings).
pattern: Option<String>Pattern constraint (regex).
Implementations§
Source§impl ParamMeta
impl ParamMeta
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the description.
Sourcepub fn deprecated(self) -> Self
pub fn deprecated(self) -> Self
Mark as deprecated.
Sourcepub fn exclude_from_schema(self) -> Self
pub fn exclude_from_schema(self) -> Self
Exclude from OpenAPI schema.
Sourcepub fn min_length(self, len: usize) -> Self
pub fn min_length(self, len: usize) -> Self
Set minimum length for strings.
Sourcepub fn max_length(self, len: usize) -> Self
pub fn max_length(self, len: usize) -> Self
Set maximum length for strings.
Sourcepub fn to_parameter(
&self,
name: impl Into<String>,
location: ParameterLocation,
required: bool,
schema: Option<Schema>,
) -> Parameter
pub fn to_parameter( &self, name: impl Into<String>, location: ParameterLocation, required: bool, schema: Option<Schema>, ) -> Parameter
Convert to an OpenAPI Parameter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParamMeta
impl RefUnwindSafe for ParamMeta
impl Send for ParamMeta
impl Sync for ParamMeta
impl Unpin for ParamMeta
impl UnsafeUnpin for ParamMeta
impl UnwindSafe for ParamMeta
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more