Support for swagger.js
SkeLLLa opened this issue · comments
It will be easier to customize swagger api and update versions if there will be support for .js
files.
Example:
const {version, description, name} = require('../package.json');
const config = require('config');
const apiConfig = config.get('api');
const serverConfig = config.get('server');
const api = {
swagger: '2.0',
info: {
title: name,
description,
version,
},
produces: ['text/plain', 'application/json'],
host: `${serverConfig.host}:${serverConfig.port}`,
basePath: apiConfig.basePath,
}
module.exports = api;
In this way version, description and all other stuff that's hardcoded now in json could be configured in proper places. And later oas will generate from this basic template swagger.json that will be used in swagger ui.
Hey! I like this idea, but it's a bit out of our scope right now. This solution is a bit long, but in the meantime you could do something like this:
node -e "console.log(JSON.stringify(require('./swagger.js')))" > swagger_temp.json && oas generate swagger_temp.json && rm swagger_temp.json
The oas
tool is just a layer for the command line. If you need more customization (like above), you can use swagger-inline
directly. oas
is mostly just a simple wrapper around swagger-inline
.