pub struct Parameter { /* private fields */ }Expand description
A single request parameter: a path segment, a query key, a header, or a cookie.
Pass it to Operation::parameter. The
value is documented as a string unless schema names
another type:
use topcoat::openapi::{Operation, Parameter};
let operation = Operation::new().parameter(
Parameter::path("post_id")
.schema::<u64>()
.description("The post to load."),
);Path parameters are documented even without an entry, because they are part of the route’s path. Add one to describe the parameter or to give it a type.
Implementations§
Source§impl Parameter
impl Parameter
Sourcepub fn path(name: impl Into<Cow<'static, str>>) -> Self
pub fn path(name: impl Into<Cow<'static, str>>) -> Self
Describes the path parameter name, written {name} in the route’s
path. A path parameter is always required.
Describes the cookie name.
Sourcepub fn description(self, description: impl Into<Cow<'static, str>>) -> Self
pub fn description(self, description: impl Into<Cow<'static, str>>) -> Self
Explains what the parameter is for.
Sourcepub fn required(self, required: bool) -> Self
pub fn required(self, required: bool) -> Self
Chooses whether a request has to send the parameter. Parameters are optional by default, except path parameters, which are always required.
Sourcepub fn schema<T: JsonSchema>(self) -> Self
pub fn schema<T: JsonSchema>(self) -> Self
Documents the parameter’s value with the schema of T, for example
.schema::<u64>() for a numeric ID.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Parameter
impl Freeze for Parameter
impl RefUnwindSafe for Parameter
impl Send for Parameter
impl Sync for Parameter
impl Unpin for Parameter
impl UnsafeUnpin for Parameter
impl UnwindSafe for Parameter
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