swagger-ui-express 配置 Authorize
-
在 路径 中这样配
"security": [ { "Bearer": [] } ]
-
在 securitySchemes 中这样配
"securitySchemes": { "Bearer": { "in": "header", "name": "jwt", "type": "http", "scheme": "bearer" } }
我用的是 express-jwt 的验证
app.use('/swagger.html', swaggerUI.serve, swaggerUI.setup(openapi)) app.use(expressjwt({ secret: '...', algorithms: ['HS256'] }).unless({ path: ['/user/login'] }))