diff --git a/utoipa-gen/Cargo.toml b/utoipa-gen/Cargo.toml index b1e04eaf..4f1df5c0 100644 --- a/utoipa-gen/Cargo.toml +++ b/utoipa-gen/Cargo.toml @@ -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 } diff --git a/utoipa-gen/tests/openapi_derive.rs b/utoipa-gen/tests/openapi_derive.rs index 50eafa0d..f84346d4 100644 --- a/utoipa-gen/tests/openapi_derive.rs +++ b/utoipa-gen/tests/openapi_derive.rs @@ -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)]