pub struct ParamMeta {Show 16 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>,
pub alias: Option<String>,
pub validation_alias: Option<String>,
pub serialization_alias: 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).
alias: Option<String>Alternative name used in request (query/header/form).
If set and validation_alias is None, this is also used for validation.
If set and serialization_alias is None, this is used for OpenAPI schema.
validation_alias: Option<String>Name used specifically for validation (overrides alias for validation).
serialization_alias: Option<String>Name used specifically for serialization/OpenAPI (overrides alias for serialization).
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 alias(self, alias: impl Into<String>) -> Self
pub fn alias(self, alias: impl Into<String>) -> Self
Set an alias for this parameter.
The alias is the alternative name used in the request (query string, header, etc.).
If validation_alias is not set, this value is also used for validation.
If serialization_alias is not set, this value is used in OpenAPI schema.
§Example
#[param(alias = "q")]
query: String, // Accepts ?q=value instead of ?query=valueSourcepub fn validation_alias(self, alias: impl Into<String>) -> Self
pub fn validation_alias(self, alias: impl Into<String>) -> Self
Set a validation-specific alias.
This name is used when validating/extracting the parameter from the request.
Overrides the general alias for validation purposes.
Sourcepub fn serialization_alias(self, alias: impl Into<String>) -> Self
pub fn serialization_alias(self, alias: impl Into<String>) -> Self
Set a serialization-specific alias.
This name is used in the OpenAPI schema for this parameter.
Overrides the general alias for serialization/OpenAPI purposes.
Sourcepub fn effective_validation_name(&self) -> Option<&str>
pub fn effective_validation_name(&self) -> Option<&str>
Get the effective name for extraction/validation.
Returns validation_alias if set, otherwise alias if set, otherwise None.
Sourcepub fn effective_serialization_name(&self) -> Option<&str>
pub fn effective_serialization_name(&self) -> Option<&str>
Get the effective name for OpenAPI/serialization.
Returns serialization_alias if set, otherwise alias if set, otherwise None.
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.
If a serialization alias is configured (via serialization_alias or alias),
it will be used as the parameter name in the OpenAPI schema.