use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
pub enum SecurityScheme {
#[serde(rename = "apiKey")]
APIKey {
#[serde(rename = "in")]
location: APIKeyLocation,
name: String,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
},
#[serde(rename = "http")]
HTTP {
scheme: String,
#[serde(rename = "bearerFormat", skip_serializing_if = "Option::is_none")]
bearer_format: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
},
#[serde(rename = "oauth2")]
OAuth2 {
flows: OAuth2Flows,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
},
#[serde(rename = "openIdConnect")]
OpenIDConnect {
#[serde(rename = "openIdConnectUrl")]
open_id_connect_url: String,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum APIKeyLocation {
Query,
Header,
Cookie,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct OAuth2Flows {
#[serde(flatten)]
pub implicit: Option<OAuth2Flow>,
#[serde(flatten)]
pub password: Option<OAuth2Flow>,
#[serde(flatten)]
pub client_credentials: Option<OAuth2Flow>,
#[serde(flatten)]
pub authorization_code: Option<OAuth2Flow>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum OAuth2Flow {
#[serde(rename_all = "camelCase")]
Implicit {
authorization_url: String,
#[serde(skip_serializing_if = "Option::is_none")]
refresh_url: Option<String>,
#[serde(default)]
scopes: IndexMap<String, String>,
},
#[serde(rename_all = "camelCase")]
Password {
#[serde(skip_serializing_if = "Option::is_none")]
refresh_url: Option<String>,
token_url: String,
#[serde(default)]
scopes: IndexMap<String, String>,
},
#[serde(rename_all = "camelCase")]
ClientCredentials {
#[serde(skip_serializing_if = "Option::is_none")]
refresh_url: Option<String>,
token_url: String,
#[serde(default)]
scopes: IndexMap<String, String>,
},
#[serde(rename_all = "camelCase")]
AuthorizationCode {
authorization_url: String,
token_url: String,
#[serde(skip_serializing_if = "Option::is_none")]
refresh_url: Option<String>,
#[serde(default)]
scopes: IndexMap<String, String>,
},
}