egg-swagger2
Not in the way of annotation to generate swagger doc by swagger 2.0.Fully support the swagger syntax configuration.Recommended for use in app/router.js
Install
$ npm i egg-swagger2 --save
Usage
// {app_root}/config/plugin.jsexportsswagger2 = enable: true package: 'egg-swagger2';
Configuration
// {app_root}/config/config.default.jsexportsswagger2 = enable:false // disable swagger , default true base: /* default config,support cover schemes: [ 'http', ], host: '127.0.0.1:7001', basePath: '/', consumes: [ 'application/json', ], produces: [ 'application/json', ], */ info: description: 'This is a test swagger-ui html' version: '1.0.0' title: 'TEST' contact: email: 'caandoll@aliyun.com' 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 ;
see config/config.default.js for more detail.
Example
// {app_root}/app/router.js module { const router controller swagger = app; router; swagger; router; swagger; };
- Schema configuration can be linked to definitions in config through $ref
- For more configuration, look at the Swagger Editor example
Questions & Suggestions
Please open an issue here.