express-swagger-ui-router

Serve swagger-ui and a local configuration file with express.js (without hacking `node_modules/swagger-ui/dist/index.html`)

Usage no npm install needed!

<script type="module">
  import expressSwaggerUiRouter from 'https://cdn.skypack.dev/express-swagger-ui-router';
</script>

README

express-swagger-ui-router NPM version

Cleanly serve swagger-ui and a local openapi configuration file.

Installation

npm install --save express-swagger-ui-router
# Install peer dependencies
npm install --save swagger-ui express 

Usage

This module exports a single function with a configFile parameter which takes the path to a local openapi configuration file. It returns an express.Router instance which can be mounted at any desired path.

import express from 'express';
import path from 'path';
import swaggerServer from 'express-swagger-ui-router';

const app = express();

app.use('/swagger',
  swaggerServer({ configFile: path.resolve(__dirname, 'openapi.json') }));

app.listen(3000);

// Access swagger-ui at localhost:3000/swagger