diff --git a/.env.example b/.env.example
index c3cd2caa3094daa00407959cfc222e7e39e601c5..56fb83cf836623dfeb1066754f2c5c2ef0994c03 100644
--- a/.env.example
+++ b/.env.example
@@ -35,3 +35,4 @@ ATTESTATION_SERVICE_HOST=0.0.0.0
 PROOF_SERVICE_TCP_PORT=8884
 PROOF_SERVICE_HOST=0.0.0.0
 
+SWAGGER=false
diff --git a/apps/agent/src/main.ts b/apps/agent/src/main.ts
index 2cec87b875f8b396da2bacd38b0401b6497a54e5..daab3ec9be703bd043331fa5346422cfe952cfad 100644
--- a/apps/agent/src/main.ts
+++ b/apps/agent/src/main.ts
@@ -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(
diff --git a/apps/gateway/src/main.ts b/apps/gateway/src/main.ts
index d3a8067253601de937ee6c35241605046973b427..46494384b6cbc276215857a7ea9994efeaaa754e 100644
--- a/apps/gateway/src/main.ts
+++ b/apps/gateway/src/main.ts
@@ -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);