egg-swagger2 icon indicating copy to clipboard operation
egg-swagger2 copied to clipboard

Available authorizations

Open sephirothwzc opened this issue 5 years ago • 0 comments

您好,目前使用 "egg-swagger2": "^1.0.4","egg": "^2.15.1", 只能全局设置api_key 设置完成后 方法中没有关联到。请问如何解决呢?

config.default.js: config.swagger2 = { enable: true, // disable swagger , default true base: { /* default config,support cover schemes: [ 'http', ], host: '127.0.0.1:7001', basePath: '/', consumes: [ 'application/json', ], produces: [ 'application/json', ], */ host: '127.0.0.1:8090', info: { description: 'This is a test swagger-ui html', version: '1.0.0', title: 'TEST', contact: { email: '[email protected]', }, license: { name: 'Apache 2.0', url: 'http://www.apache.org/licenses/LICENSE-2.0.html', }, }, tags: [ { name: 'admin', description: 'Admin desc', }, { name: 'role', description: 'Role desc', }, ], definitions: { // model definitions }, securityDefinitions: { // security definitions api_key: { type: 'apiKey', name: 'api_key', in: 'header', }, }, }, }; router.js: swagger.get('/card-settings/background-img', { tags: [ 'admin', ], summary: 'Login a admin', description: '获取会员卡背景图', responses: { 200: { description: 'SUCCEED', schema: { type: 'object', properties: { url: { type: 'string', description: '背景图路径', }, }, }, }, }, security: { api_key: [], }, });

sephirothwzc avatar May 08 '19 07:05 sephirothwzc