fix(openapi): moved write-api to public/openapi

v1.18.x
Julian Lam 5 years ago
parent 3072de4812
commit 49994f3a15

@ -1,13 +1,12 @@
openapi: 3.0.0
info:
description: 'Standard, out-of-the-box read & write API for NodeBB v2.0+'
description: 'Write API for NodeBB v2.0+'
version: 31-03-2020
title: Read/Write API
title: Write API
contact:
email: support@nodebb.org
license:
name: MIT
url: 'https://opensource.org/licenses/MIT'
name: GPL-3.0
servers:
- url: /api/v1
tags:

@ -14,14 +14,20 @@ module.exports = function (app) {
});
// Redoc
router.get('/spec/read', async (req, res) => {
router.get('/spec/:type', async (req, res, next) => {
const types = ['read', 'write'];
const type = req.params.type;
if (!types.includes(type)) {
return next();
}
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');
html = html.replace('apiUrl', nconf.get('relative_path') + '/assets/openapi/' + type + '.yaml');
res.status(200).type('text/html').send(html);
});

Loading…
Cancel
Save