小编akh*_*301的帖子

如何使用 JWT 令牌授权 Swagger jsdoc?

我已经定义了我的 swagger 定义,如下所示:

const swaggerDefinition = {
  info: {
    title: 'Node Swagger API',
    version: '1.0.0',
    description: 'Describing a RESTful API with Swagger',
  },
  host: 'localhost:8000',
  basePath: '/',
  securityDefinitions: {
    JWT: {
      type: 'apiKey',
      description: 'JWT authorization of an API',
      name: 'Authorization',
      in: 'header',
    },
  },
};
Run Code Online (Sandbox Code Playgroud)

但是我无法在 swagger UI 甚至 swagger.json 中获得任何授权

    info: {
       title: "Node Swagger API",
       version: "1.0.0",
       description: "Describing a RESTful API with Swagger"
    },
    host: "localhost:8000",
    basePath: "/",
    securityDefinitions: { },
    swagger: "2.0",
Run Code Online (Sandbox Code Playgroud)

securitydefinitions 块在 swagger.json …

node.js jwt swagger swagger-ui swagger-2.0

1
推荐指数
1
解决办法
5578
查看次数

标签 统计

jwt ×1

node.js ×1

swagger ×1

swagger-2.0 ×1

swagger-ui ×1