use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use std::collections::BTreeMap;
use crate::types::ParameterIn;
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
pub enum SecurityType {
ApiKey {
name: String,
#[serde(rename = "in")]
_in: ParameterIn,
},
Http {
scheme: String,
#[serde(rename = "bearerFormat")]
bearer_format: Option<String>,
},
Oauth2 {
flows: OauthFlows,
},
OpenIdConnect {
#[serde(rename = "openIdConnectUrl")]
open_id_connect_url: String,
},
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecurityScheme {
#[serde(flatten)]
pub _type: SecurityType,
pub description: Option<String>,
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OauthFlows {
pub implicit: Option<OauthFlow>,
pub password: Option<OauthFlow>,
pub client_credentials: Option<OauthFlow>,
pub authorization_code: Option<OauthFlow>,
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OauthFlow {
pub authorization_url: String,
pub token_url: Option<String>,
pub refresh_url: Option<String>,
pub scopes: BTreeMap<String, String>,
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(transparent)]
pub struct SecurityRequirement {
#[serde(flatten)]
pub data: BTreeMap<String, Vec<String>>,
}