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 for SecurityRequirement
impl PartialEq for SecurityRequirement
source§impl Serialize for SecurityRequirement
impl Serialize for SecurityRequirement
impl Eq for SecurityRequirement
impl StructuralPartialEq for SecurityRequirement
Auto Trait Implementations§
impl Freeze for SecurityRequirement
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.