0.1.2 • Published 3 years ago

egg-swagger-static v0.1.2

Weekly downloads
48
License
MIT
Repository
github
Last release
3 years ago

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