Skip to content

Commit

Permalink
Add test for logical or security requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaku committed Sep 5, 2024
1 parent b0ae6ef commit af79ed6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion utoipa-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ulid = { version = "1", optional = true, default-features = false }
url = { version = "2", optional = true }

[dev-dependencies]
utoipa = { path = "../utoipa", features = ["debug", "uuid"], default-features = false }
utoipa = { path = "../utoipa", features = ["debug", "uuid", "macros"], default-features = false }
serde_json = "1"
serde = "1"
actix-web = { version = "4", features = ["macros"], default-features = false }
Expand Down
23 changes: 23 additions & 0 deletions utoipa-gen/tests/openapi_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ fn derive_openapi_with_security_requirement() {
}
}

#[test]
fn derive_logical_or_security_requirement() {
#[derive(Default, OpenApi)]
#[openapi(security(
("oauth" = ["a"]),
("oauth" = ["b"]),
))]
struct ApiDoc;

let doc_value = serde_json::to_value(ApiDoc::openapi()).unwrap();
let security = doc_value
.pointer("/security")
.expect("should have security requirements");

assert_json_eq!(
security,
json!([
{"oauth": ["a"]},
{"oauth": ["b"]},
])
);
}

#[test]
fn derive_openapi_tags() {
#[derive(OpenApi)]
Expand Down

0 comments on commit af79ed6

Please sign in to comment.