diff --git a/openapi.yaml b/public/openapi/write.yaml similarity index 99% rename from openapi.yaml rename to public/openapi/write.yaml index e181a27d6216..65248c63e75b 100644 --- a/openapi.yaml +++ b/public/openapi/write.yaml @@ -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: diff --git a/src/routes/debug.js b/src/routes/debug.js index b55c1f2440a4..189dda4e9cbe 100644 --- a/src/routes/debug.js +++ b/src/routes/debug.js @@ -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); });