From 7c88c7ee6b75e92b9578cfd38c7fc8ba7993ed81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Gonz=C3=A1lez?= Date: Mon, 18 Mar 2024 09:47:05 +0100 Subject: [PATCH] Fixing OpenAPI E2E Tests - Reemplace the host IP for production in the specification file - Changed the routes to avoid Fnotfound during the E2E test suite execution --- .github/workflows/release.yml | 4 ++++ gatewayservice/gateway-service.js | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cb96d06b..48a92d37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,6 +102,10 @@ jobs: needs: [e2e-tests] steps: - uses: actions/checkout@v4 + - name: Update OpenAPI configuration + run: | + DEPLOY_HOST=${{ secrets.DEPLOY_HOST }} + sed -i "s/SOMEIP/${DEPLOY_HOST}/g" gatewayservice/openapi.yaml - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 with: diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 84d7d8fa..444b71dc 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -47,15 +47,20 @@ app.post('/adduser', async (req, res) => { }); // Read the OpenAPI YAML file synchronously -const file = fs.readFileSync('./openapi.yaml', 'utf8'); +openapiPath='./openapi.yaml' +if (fs.existsSync(openapiPath)) { + const file = fs.readFileSync(openapiPath, 'utf8'); -// Parse the YAML content into a JavaScript object representing the Swagger document -const swaggerDocument = YAML.parse(file); + // Parse the YAML content into a JavaScript object representing the Swagger document + const swaggerDocument = YAML.parse(file); -// Serve the Swagger UI documentation at the '/api-doc' endpoint -// This middleware serves the Swagger UI files and sets up the Swagger UI page -// It takes the parsed Swagger document as input -app.use('/api-doc', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); + // Serve the Swagger UI documentation at the '/api-doc' endpoint + // This middleware serves the Swagger UI files and sets up the Swagger UI page + // It takes the parsed Swagger document as input + app.use('/api-doc', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); +} else { + console.log("Not configuring OpenAPI. Configuration file not present.") +} // Start the gateway service const server = app.listen(port, () => {