#[non_exhaustive]pub struct SecurityRequirement { /* private fields */ }
Expand description
OpenAPI security requirment object.
Security requirement holds list of required SecurityScheme
names and possible scopes required
to execute the operation. They can be defined in #[utoipa::path(...)]
or in #[openapi(...)]
of OpenApi
.
Applying the security requirement to OpenApi
will make it globally
available to all operations. When applied to specific #[utoipa::path(...)]
will only
make the security requirements available for that operation. Only one of the requirements must be
satisfied.
Implementations
sourceimpl SecurityRequirement
impl SecurityRequirement
sourcepub fn new<N: Into<String>, S: IntoIterator<Item = I>, I: Into<String>>(
name: N,
scopes: S
) -> Self
pub fn new<N: Into<String>, S: IntoIterator<Item = I>, I: Into<String>>(
name: N,
scopes: S
) -> Self
Construct a new SecurityRequirement
Accepts name for the security requirement which must match to the name of available SecurityScheme
.
Second parameter is IntoIterator
of Into<String>
scopes needed by the SecurityRequirement
.
Scopes must match to the ones defined in SecurityScheme
.
Examples
Create new security requirement with scopes.
SecurityRequirement::new("api_oauth2_flow", ["edit:items", "read:items"]);
You can also create an empty security requirement with Default::default()
.
SecurityRequirement::default();
Trait Implementations
sourceimpl Clone for SecurityRequirement
impl Clone for SecurityRequirement
sourcefn clone(&self) -> SecurityRequirement
fn clone(&self) -> SecurityRequirement
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SecurityRequirement
impl Debug for SecurityRequirement
sourceimpl Default for SecurityRequirement
impl Default for SecurityRequirement
sourcefn default() -> SecurityRequirement
fn default() -> SecurityRequirement
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for SecurityRequirement
impl<'de> Deserialize<'de> for SecurityRequirement
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Serialize for SecurityRequirement
impl Serialize for SecurityRequirement
Auto Trait Implementations
impl RefUnwindSafe for SecurityRequirement
impl Send for SecurityRequirement
impl Sync for SecurityRequirement
impl Unpin for SecurityRequirement
impl UnwindSafe for SecurityRequirement
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more