Skip to main content

ParamMeta

Struct ParamMeta 

Source
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: bool

Whether the parameter is deprecated.

§include_in_schema: bool

Whether 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

Source

pub fn new() -> Self

Create a new parameter metadata with default values.

Source

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

Set the title.

Source

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

Set the description.

Source

pub fn deprecated(self) -> Self

Mark as deprecated.

Source

pub fn exclude_from_schema(self) -> Self

Exclude from OpenAPI schema.

Source

pub fn example(self, example: Value) -> Self

Set an example value.

Source

pub fn ge(self, value: f64) -> Self

Set minimum value constraint (>=).

Source

pub fn le(self, value: f64) -> Self

Set maximum value constraint (<=).

Source

pub fn gt(self, value: f64) -> Self

Set exclusive minimum constraint (>).

Source

pub fn lt(self, value: f64) -> Self

Set exclusive maximum constraint (<).

Source

pub fn min_length(self, len: usize) -> Self

Set minimum length for strings.

Source

pub fn max_length(self, len: usize) -> Self

Set maximum length for strings.

Source

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

Set a regex pattern constraint.

Source

pub fn to_parameter( &self, name: impl Into<String>, location: ParameterLocation, required: bool, schema: Option<Schema>, ) -> Parameter

Convert to an OpenAPI Parameter.

Trait Implementations§

Source§

impl Clone for ParamMeta

Source§

fn clone(&self) -> ParamMeta

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParamMeta

Source§

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

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

impl Default for ParamMeta

Source§

fn default() -> ParamMeta

Returns the “default value” for a type. Read more

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.