-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
See https://swagger.io/docs/specification/authentication/
Currently we only support OR for security models: if you specify multiple security models, if any of them passes auth passes.
OpenAPI supports combing OR and AND.
Technically you can achieve this by setting auto_error=False, but this isn't reflected in OpenAPI.
A better approach would be something like:
from dataclasses import data class
from xpresso import AnyOfSecurity
@dataclass
class SecurityModels:
key1: Annotated[str, Security(...)]
key2: Annotated[str, Security(...)]
async def endpoint(security: AnyOfSecurity[SecurityModels]) -> None:
...AnyOfSecurity would just be Dependent subclass, with no effect on runtime, but that we can use when generating OpenAPI docs.
This has a nice parallel with how we handle forms.
Metadata
Metadata
Assignees
Labels
No labels