Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Arquisoft/wiq_en2a
Browse files Browse the repository at this point in the history
  • Loading branch information
carolbgmm committed Apr 29, 2024
2 parents 714a92e + aeeee11 commit 8d88e73
Show file tree
Hide file tree
Showing 6 changed files with 795 additions and 10 deletions.
21 changes: 21 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const axios = require('axios');
const cors = require('cors');
const promBundle = require('express-prom-bundle');

// libraries required for OpenAPI-Swagger
const swaggerUI = require('swagger-ui-express');
const fs = require("fs");
const YAML = require('yaml');

const app = express();
const port = 8000;

Expand Down Expand Up @@ -182,6 +187,22 @@ app.get('/getGroups', async (req, res) => {
}
})

// Read the OpenAPI YAML file synchronously
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);

// 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, () => {
Expand Down
Loading

0 comments on commit 8d88e73

Please sign in to comment.