diff --git a/public/vendor/redoc/index.html b/public/vendor/redoc/index.html new file mode 100644 index 0000000000..342866d600 --- /dev/null +++ b/public/vendor/redoc/index.html @@ -0,0 +1,24 @@ + + + + ReDoc + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/routes/debug.js b/src/routes/debug.js index 460534fcdc..b55c1f2440 100644 --- a/src/routes/debug.js +++ b/src/routes/debug.js @@ -3,6 +3,9 @@ var express = require('express'); var nconf = require('nconf'); +const fs = require('fs').promises; +const path = require('path'); + module.exports = function (app) { var router = express.Router(); @@ -10,5 +13,17 @@ module.exports = function (app) { res.redirect(404); }); + // Redoc + router.get('/spec/read', async (req, res) => { + const handle = await fs.open(path.resolve(__dirname, '../../public/vendor/redoc/index.html'), 'r'); + let html = await handle.readFile({ + encoding: 'utf-8', + }); + await handle.close(); + + html = html.replace('apiUrl', nconf.get('relative_path') + '/assets/openapi/read.yaml'); + res.status(200).type('text/html').send(html); + }); + app.use(nconf.get('relative_path') + '/debug', router); };