繁体   English   中英

在 swagger 上将 Authorization Bearer 添加到 header

[英]Adding Authorization Bearer to header on swagger

我正在尝试使用 swagger ui,但我无法在 swagger ui 上进行身份验证。

server.js

    const swaggerDefinition = JSON.parse(fs.readFileSync( "./swagger.json" ));
    
    const swaggerOptions = swaggerDefinition;
    
    const swaggerDocs = swaggerJsDoc(swaggerOptions);
    
    app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));

swagger.json



"host": "localhost:5000",
    "basePath": "/api",
    "schemes": [
      "http"
    ],
    "securityDefinitions": {
      "Bearer" : {
        "type": "access_token",
        "name": "Authorization",
        "in": "header"
      }
    }

我在邮递员上使用这样的(它的作品)

邮递员标题在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM