Skip to content

Commit

Permalink
Fix the SecurityScheme definition (#9)
Browse files Browse the repository at this point in the history
For `{"type": "http", "scheme": "basic"}` no `bearer_format`, is
provided, so make that field optional.
  • Loading branch information
weiznich authored Nov 7, 2023
1 parent f2d0a6b commit abe9e25
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/spec/security_scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum SecurityScheme {
Http {
scheme: String,
#[serde(rename = "bearerFormat")]
bearer_format: String,
bearer_format: Option<String>,
},

#[serde(rename = "oauth2")]
Expand All @@ -45,6 +45,20 @@ mod tests {
use super::*;
use url::Url;

#[test]
fn test_http_basic_deser() {
const HTTP_BASIC_SAMPLE: &str = r#"{"type": "http", "scheme": "basic"}"#;
let obj: SecurityScheme = serde_json::from_str(&HTTP_BASIC_SAMPLE).unwrap();

assert!(matches!(
obj,
SecurityScheme::Http {
scheme,
bearer_format: None,
} if scheme == "basic"
));
}

#[test]
fn test_security_scheme_oauth_deser() {
const IMPLICIT_OAUTH2_SAMPLE: &str = r#"{
Expand Down

0 comments on commit abe9e25

Please sign in to comment.