Package Exports
- redoc-express
- redoc-express/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redoc-express) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
redoc-express
Express Middleware for OpenAPI/Swagger-generated API Reference Documentation
Demo
Install
npm install redoc-expressUsage
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 iRun Test
npm tTest Coverage
| Metric | Coverage |
|---|---|
| Statements | 100% |
| Branches | 100% |
| Functions | 100% |
| Lines | 100% |
47 comprehensive test cases covering:
- HTML template generation with various configurations
- Special characters and edge cases handling
- Middleware functionality and request/response handling
- Complex nested options and JSON serialization
- Daily CI/CD test runs with automated issue creation
Check ReDoc Project for more INFO
License
MIT © Aung Myo Kyaw