Struct utoipa::openapi::security::SecurityRequirement
source · #[non_exhaustive]pub struct SecurityRequirement { /* private fields */ }
Expand description
OpenAPI security requirement 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§
source§impl 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§
source§impl Clone for SecurityRequirement
impl Clone for SecurityRequirement
source§fn clone(&self) -> SecurityRequirement
fn clone(&self) -> SecurityRequirement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SecurityRequirement
impl Debug for SecurityRequirement
source§impl Default for SecurityRequirement
impl Default for SecurityRequirement
source§fn default() -> SecurityRequirement
fn default() -> SecurityRequirement
source§impl<'de> Deserialize<'de> for SecurityRequirement
impl<'de> Deserialize<'de> for SecurityRequirement
source§fn 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>,
source§impl PartialEq<SecurityRequirement> for SecurityRequirement
impl PartialEq<SecurityRequirement> for SecurityRequirement
source§fn eq(&self, other: &SecurityRequirement) -> bool
fn eq(&self, other: &SecurityRequirement) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for SecurityRequirement
impl Serialize for SecurityRequirement
impl Eq for SecurityRequirement
impl StructuralEq for SecurityRequirement
impl StructuralPartialEq 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§
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.