An OpenAPI security scheme describes how an HTTP API authenticates or authorizes callers. Defining the scheme lets Swagger UI understand the protection mechanism and provide an authorization workflow for testing protected operations. section 25.5
Configure a scheme in two steps:
- Define the mechanism, such as JWT bearer authentication, OAuth 2.0, OpenID Connect, or simple bearer authentication. section 25.5
- Declare which endpoints use the scheme by adding a security requirement; applying it globally protects the whole API. section 25.5 section 25.7
- Register an OpenApiSecurityScheme with Swashbuckle using AddSecurityDefinition(), then connect it with AddSecurityRequirement(). section 25.7
JWT bearer authentication in Swagger UI
After registering a bearer scheme, Swagger UI displays an Authorize button. Enter Bearer <token>, including the space and prefix; Swagger UI then saves the value and attaches it to subsequent requests in the Authorization header. section 25.5


