You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenAPI security requirements are an OR-list at the operation level:
security: [ { ApiKey: [] }, { BearerAuth: [] } ] means either ApiKey or BearerAuth
In practice it’s common to support multiple auth mechanisms during migrations (API key OR bearer JWT), or to have alternative schemes.
With aide’s current ergonomics (notably TransformOperation::security_requirement / security_requirement_scopes), it’s easy to accidentally model security as a single requirement object, and it’s not obvious how to express OR cleanly.
Related issues
How to require multiple securitySchemas? #25 is about requiring multiple schemes in a group / confusion around the schema shape, but this issue is specifically about providing an ergonomic way to express OR across security requirements.
Proposed solution
Add a helper API that makes OR explicit and hard to misuse, e.g.
or a lower-level op.security_requirements(vec![SecurityRequirement::from("ApiKey"), SecurityRequirement::from("BearerAuth")])
or builder helpers on openapi::OpenApi / TransformOperation that mirror the OpenAPI structure.
Expected output (example)
security:
- ApiKey: []
- BearerAuth: []
Minimal example use-case
.api_route_with("/v1/foo",get(foo), |op| op, |op| {// would like an ergonomic way to express:// either API key or bearer token
op /* .security_requirement_or(["ApiKey", "BearerAuth"]) */})
Additional context
I searched issues for SecurityRequirement, anyOf security, OR security requirement, etc. and didn’t find a dedicated issue for this ergonomic gap.
Problem
OpenAPI security requirements are an OR-list at the operation level:
security: [ { ApiKey: [] }, { BearerAuth: [] } ]means either ApiKey or BearerAuthIn practice it’s common to support multiple auth mechanisms during migrations (API key OR bearer JWT), or to have alternative schemes.
With aide’s current ergonomics (notably
TransformOperation::security_requirement/security_requirement_scopes), it’s easy to accidentally model security as a single requirement object, and it’s not obvious how to express OR cleanly.Related issues
Proposed solution
Add a helper API that makes OR explicit and hard to misuse, e.g.
op.security_requirement_or(["ApiKey", "BearerAuth"])op.security_requirements(vec![SecurityRequirement::from("ApiKey"), SecurityRequirement::from("BearerAuth")])openapi::OpenApi/TransformOperationthat mirror the OpenAPI structure.Expected output (example)
Minimal example use-case
Additional context
I searched issues for
SecurityRequirement,anyOf security,OR security requirement, etc. and didn’t find a dedicated issue for this ergonomic gap.