Skip to content

Commit

Permalink
fix(openapi): moved write-api to public/openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Oct 8, 2020
1 parent 3072de4 commit 49994f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 3 additions & 4 deletions openapi.yaml → 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:
Expand Down
10 changes: 8 additions & 2 deletions src/routes/debug.js
Expand Up @@ -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);
});

Expand Down

0 comments on commit 49994f3

Please sign in to comment.