Struct utoipa::openapi::security::SecurityRequirement
source · #[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
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more