From 380531146712eae2c030874e7b81c76b815d290e Mon Sep 17 00:00:00 2001 From: jeevitha011 <118245189+jeevitha011@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:30:15 +0530 Subject: [PATCH] Update server.js (#6) --- xmpl/srv/server.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xmpl/srv/server.js b/xmpl/srv/server.js index 0b27ad2..b199465 100644 --- a/xmpl/srv/server.js +++ b/xmpl/srv/server.js @@ -1,8 +1,13 @@ -const cds = require('../../cds-plugin') +const cds = require('../../cds-plugin'); +const fs = require('fs'); -async function generateOpenAPI (filePath) { - const openapiFile = await cds.compile(`file:${filePath}`).to.openapi({ service: "ProcessorService" }); - console.log(openapiFile) +async function generateOpenAPI(filePath) { + const openapiDocument = await cds.compile(`file:${filePath}`).to.openapi({ service: "ProcessorService" }); // to generate document for single service + fs.writeFile('./openapi.json', JSON.stringify(openapiDocument), err => { + if (err) { + console.error(err); + } + }); } generateOpenAPI('./srv/services.cds')