Skip to content

Latest commit

 

History

History
90 lines (70 loc) · 2.51 KB

README.md

File metadata and controls

90 lines (70 loc) · 2.51 KB

egg-swagger-static

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-swagger-static --save

Usage

// {app_root}/config/plugin.js
exports.swaggerStatic = {
  enable: true,
  package: 'egg-swagger-static',
};

Configuration

// {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
    },
  ],
};

Add Api docs with the specification of OpenAPI

Refer to template: swagger.yml.
Add api.yml or api.json in the root dir of project.

Visit Api Page

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.

Example

Questions & Suggestions

Please open an issue here.

License

MIT