$ npm i egg-swagger-static --save
// {app_root}/config/plugin.js
exports.swaggerStatic = {
enable: true,
package: 'egg-swagger-static',
};
// {app_root}/config/config.default.js
const swaggerPath = require('egg-swagger-static').getAbsoluteFSPath();
// exports.swaggerStatic = {
// NOT USE.
// };
// Add config of the built-in plugin: egg-static
config.static = {
maxAge: 31536000,
// prefix: '/swg',
// dir: swaggerPath,
dir: [
// swaggerPath,
{
prefix: '/swg',
dir: swaggerPath
},
],
};
Refer to template: swagger.yml.
Add api.yml or api.json in the root dir of project.
Api Page: http://[SERVRT_IP]:[SERVRT_PORT]/swg/index.html
see config/config.default.js for more detail.
see egg-static for more detail.
see swagger-ui/dist for more detail.
see OpenAPI for more detail.
Please open an issue here.