forked from SmartDropLabs/smartdrop-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiDocs.js
More file actions
26 lines (21 loc) · 724 Bytes
/
Copy pathapiDocs.js
File metadata and controls
26 lines (21 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const express = require('express');
const path = require('path');
const YAML = require('yamljs');
const swaggerUi = require('swagger-ui-express');
const config = require('../config');
const router = express.Router();
const openApiDocument = YAML.load(path.join(__dirname, '../../openapi.yaml'));
router.get('/openapi.yaml', (_req, res) => {
res.type('yaml').sendFile(path.join(__dirname, '../../openapi.yaml'));
});
if (config.nodeEnv === 'development') {
router.use('/', swaggerUi.serve, swaggerUi.setup(openApiDocument, {
explorer: true,
customSiteTitle: 'SmartDrop API Docs',
}));
} else {
router.get('/', (_req, res) => {
res.redirect('/api-docs/openapi.yaml');
});
}
module.exports = router;