Skip to content

AungMyoKyaw/redoc-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Aung Myo Kyaw
May 5, 2023
788d2dd · May 5, 2023

History

12 Commits
May 5, 2023
May 5, 2023
Nov 3, 2019
Nov 3, 2019
Nov 3, 2019
Nov 3, 2019
May 5, 2023
Nov 2, 2019
May 5, 2023
Nov 3, 2019
May 5, 2023
Nov 3, 2019

Repository files navigation

Express Middleware for OpenAPI/Swagger-generated API Reference Documentation

code style: prettier npm contributions welcome License: MIT

Demo

Install

npm install redoc-express

Usage

const express = require('express');
const redoc = require('redoc-express');

const app = express();
const port = 3000;

// serve your swagger.json file
app.get('/docs/swagger.json', (req, res) => {
  res.sendFile('swagger.json', { root: '.' });
});

// define title and specUrl location
// serve redoc
app.get(
  '/docs',
  redoc({
    title: 'API Docs',
    specUrl: '/docs/swagger.json',
    nonce: '', // <= it is optional,we can omit this key and value
    // we are now start supporting the redocOptions object
    // you can omit the options object if you don't need it
    // https://redocly.com/docs/api-reference-docs/configuration/functionality/
    redocOptions: {
      theme: {
        colors: {
          primary: {
            main: '#6EC5AB'
          }
        },
        typography: {
          fontFamily: `"museo-sans", 'Helvetica Neue', Helvetica, Arial, sans-serif`,
          fontSize: '15px',
          lineHeight: '1.5',
          code: {
            code: '#87E8C7',
            backgroundColor: '#4D4D4E'
          }
        },
        menu: {
          backgroundColor: '#ffffff'
        }
      }
    }
  })
);

app.listen(port, () => console.log(`Example app listening on port ${port}!`));

Development

Install Dependencies

npm i

Run Test

npm t

Check ReDoc Project for more INFO

License

MIT © Aung Myo Kyaw