koas-swagger-ui

0.7.0 • Public • Published

Koas Swagger UI

Koas Swagger UI serves Swagger UI. This requires the specURL variable to have been set on the ctx.openApi object. Typically this is done by combining it with koas-spec-handler.

Note: Since this serves static files from swagger-ui-dist, this can’t be used with a module bundler.

Installation

npm install koa koas-core koas-spec-handler koas-swagger-ui

Usage

const Koa = require('koa');
const { koas } = require('koas-core');
const { specHandler } = require('koas-spec-handler');
const { swaggerUI } = require('koas-swagger-uit');

const api = require('./api.json');

const app = new Koa();
app.use(
  koas(api, [
    specHandler(),
    swaggerUI({
      plugins: [
        // Plugins
      ],
      presets: [
        // Presets
      ],
      url: '',
    }),
  ]),
);

Options

  • plugins: This is a list of strings which specifies which plugins should be loaded into Swagger UI. The values can be taken from the koasSwaggerUI.plugins mapping.
  • presets: This is a list of strings which specifies which presets should be loaded into Swagger UI. The values can be taken from the koasSwaggerUI.presets mapping.
  • url: The URL on which Swagger UI is hosted. By default this is hosted on the root URL.

Package Sidebar

Install

npm i koas-swagger-ui

Weekly Downloads

2,444

Version

0.7.0

License

MIT

Unpacked Size

19.6 kB

Total Files

10

Last publish

Collaborators

  • remcohaszing