Swagger API
此篇在eggjs上,安装swagger,那么这个eggjs大概能用了。
egg-swagger-doc
- 在npmjs 上搜索 egg-swagger-doc,然后安装:
npm install --save egg-swagger-doc
- 打开插件
在app/config/plugin.js中配置
// {app_root}/config/plugin.js
exports.swaggerdoc = {
enable: true,
package: 'egg-swagger-doc',
};
- 配置插件
exports.swaggerdoc = {
dirScanner: './app/controller',
apiInfo: {
title: 'egg-swagger',
description: 'swagger-ui for egg',
version: '1.0.0',
},
schemes: ['http', 'https'],
consumes: ['application/json'],
produces: ['application/json'],
securityDefinitions: {
// apikey: {
// type: 'apiKey',
// name: 'clientkey',
// in: 'header',
// },
// oauth2: {
// type: 'oauth2',
// tokenUrl: 'http://petstore.swagger.io/oauth/dialog',
// flow: 'password',
// scopes: {
// 'write:access_token': 'write access_token',
// 'read:access_token&#