Skip to content
Snippets Groups Projects
Unverified Commit 8a069668 authored by Zdravko Iliev's avatar Zdravko Iliev
Browse files

feat: add env flag for swagger in agent rest api and gatewat rest api

parent 67d4285e
No related branches found
No related tags found
1 merge request!46fix: separate swagger generation from server run
Pipeline #67387 passed with stage
in 2 minutes and 4 seconds
This commit is part of merge request !46. Comments created here will be created in the context of that merge request.
......@@ -17,15 +17,19 @@ async function bootstrap() {
const port = process.env.AGENT_PORT || 3001;
app.enableShutdownHooks();
const config = new DocumentBuilder()
.setTitle("Agent")
.setDescription("Agent API")
.setVersion("1.0")
.build();
if (process.env.SWAGGER === "true") {
const config = new DocumentBuilder()
.setTitle("Agent")
.setDescription("Agent API")
.setVersion("1.0")
.build();
const document = SwaggerModule.createDocument(app, config);
fs.writeFileSync("./agent-swagger.json", JSON.stringify(document));
SwaggerModule.setup("api", app, document);
const document = SwaggerModule.createDocument(app, config);
fs.writeFileSync("./agent-swagger.json", JSON.stringify(document));
SwaggerModule.setup("api", app, document);
Logger.log(`Swagger file written`);
return process.kill(0);
}
await app.listen(port, "0.0.0.0");
Logger.log(
......
......@@ -38,17 +38,21 @@ async function bootstrap() {
app.enableShutdownHooks();
const config = new DocumentBuilder()
.setTitle("OCM Gateway")
.setDescription("OCM ENGINE GATEWAY API")
.setVersion("1.0")
.addServer(`http://${gatewayConfig.host}:${gatewayConfig.httpPort}`)
.build();
if (process.env.SWAGGER === "true") {
const config = new DocumentBuilder()
.setTitle("OCM Gateway")
.setDescription("OCM ENGINE GATEWAY API")
.setVersion("1.0")
.addServer(`http://${gatewayConfig.host}:${gatewayConfig.httpPort}`)
.build();
const document = SwaggerModule.createDocument(app, config);
fs.writeFileSync("./gateway-swagger.json", JSON.stringify(document));
SwaggerModule.setup("api", app, document);
const document = SwaggerModule.createDocument(app, config);
fs.writeFileSync("./gateway-swagger.json", JSON.stringify(document));
SwaggerModule.setup("api", app, document);
Logger.log(`Swagger file written`);
return process.kill(0);
}
const port = gatewayConfig.httpPort || 3000;
await app.listen(port, gatewayConfig.host);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment