pub enum SecurityScheme {
Http {
scheme: String,
bearer_format: Option<String>,
description: Option<String>,
},
ApiKey {
name: String,
location: ApiKeyLocation,
description: Option<String>,
},
OAuth2 {
flows: Box<OAuth2Flows>,
description: Option<String>,
},
}Expand description
认证方案,支持 HTTP(Basic/Bearer)、ApiKey、OAuth2
Variants§
Http
HTTP 认证(Basic 或 Bearer)
OpenAPI 3.0 中 Basic 和 Bearer 都使用 type: http,
通过 scheme 字段区分(basic 或 bearer)。
Fields
ApiKey
API Key 认证(Header / Query / Cookie)
OAuth2
OAuth2 认证
Implementations§
Source§impl SecurityScheme
impl SecurityScheme
Sourcepub fn api_key(name: &str, location: ApiKeyLocation) -> Self
pub fn api_key(name: &str, location: ApiKeyLocation) -> Self
创建 API Key 认证方案
Sourcepub fn oauth2(flows: OAuth2Flows) -> Self
pub fn oauth2(flows: OAuth2Flows) -> Self
创建 OAuth2 认证方案
Sourcepub fn with_description(self, desc: &str) -> Self
pub fn with_description(self, desc: &str) -> Self
设置描述
Trait Implementations§
Source§impl Clone for SecurityScheme
impl Clone for SecurityScheme
Source§fn clone(&self) -> SecurityScheme
fn clone(&self) -> SecurityScheme
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecurityScheme
impl Debug for SecurityScheme
Source§impl<'de> Deserialize<'de> for SecurityScheme
impl<'de> Deserialize<'de> for SecurityScheme
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SecurityScheme
impl RefUnwindSafe for SecurityScheme
impl Send for SecurityScheme
impl Sync for SecurityScheme
impl Unpin for SecurityScheme
impl UnsafeUnpin for SecurityScheme
impl UnwindSafe for SecurityScheme
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