Node.js based forum software built for the modern web
fix(openapi): moved write-api to public/openapi
Julian Lam49994f3a1526
diff --git a/openapi.yaml b/public/openapi/write.yamlsimilarity index 99%rename from openapi.yamlrename to public/openapi/write.yamlindex e181a27d62..65248c63e7 100644--- a/openapi.yaml+++ b/public/openapi/write.yaml@@ -1,13 +1,12 @@openapi: 3.0.0info:- 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 APIcontact:email: [email protected]license:- name: MIT- url: 'https://opensource.org/licenses/MIT'+ name: GPL-3.0servers:- url: /api/v1tags:diff --git a/src/routes/debug.js b/src/routes/debug.jsindex b55c1f2440..189dda4e9c 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);});