egg-swagger-static

0.1.2 • Public • Published

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

Package Sidebar

Install

npm i egg-swagger-static

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

6.89 MB

Total Files

14

Last publish

Collaborators

  • senique