Skip to content

Commit

Permalink
Merge pull request #74 from Arquisoft/openapi
Browse files Browse the repository at this point in the history
Test de stats, ranking y perfil. Openapi
  • Loading branch information
iyanfdezz authored Apr 1, 2024
2 parents 50bae90 + bfc765e commit 5846d72
Show file tree
Hide file tree
Showing 12 changed files with 875 additions and 148 deletions.
19 changes: 18 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const express = require("express");
const axios = require("axios");
const cors = require("cors");
const promBundle = require("express-prom-bundle");

const YAML = require('yaml');
const fs = require("fs");
const swaggerUi = require('swagger-ui-express');
const app = express();
const port = 8000;

Expand Down Expand Up @@ -155,6 +157,21 @@ app.get("/ranking", async (req, res) => {
}
});

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, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
Loading

0 comments on commit 5846d72

Please sign in to comment.