mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
fix(openapi): moved write-api to public/openapi
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user