Files
e-commerce/loaders/swagger.js
2022-09-26 16:24:35 -05:00

11 lines
441 B
JavaScript

const swaggerUI = require('swagger-ui-express');
const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
// Loading via yml.safeLoad to avoid errors with special characters during processing
const swaggerDocument = yaml.load(fs.readFileSync(path.resolve(__dirname, '../swagger.yml'), 'utf8'));
module.exports = async (app) => {
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument));
}