From 94de639184118911aed62bf329d6ed75d3648d6a Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Thu, 25 Apr 2024 17:55:08 +0200 Subject: [PATCH 01/10] Added the openai.yaml file --- gatewayservice/openapi.yaml | 144 ++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 gatewayservice/openapi.yaml diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml new file mode 100644 index 00000000..285e7c56 --- /dev/null +++ b/gatewayservice/openapi.yaml @@ -0,0 +1,144 @@ +openapi: 3.0.0 +info: + title: Gatewayservice API + description: Gateway OpenAPI specification. + version: 0.2.0 +servers: + - url: http://localhost:8000 + description: Development server + - url: http://SOMEIP:8000 + description: Production server +paths: + /adduser: + post: + summary: Add a new user to the database. + operationId: addUser + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: User ID. + example: student + password: + type: string + description: User password. + example: pass + responses: + '200': + description: User added successfully. + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: User ID + password: + type: string + description: Hashed password + example: $2b$10$ZKdNYLWFQxzt5Rei/YTc/OsZNi12YiWz30JeUFHNdAt7MyfmkTuvC + _id: + type: string + description: Identification + example: 65f756db3fa22d227a4b7c7d + createdAt: + type: string + description: Creation date. + example: '2024-03-17T20:47:23.935Z' + ___v: + type: integer + example: '0' + '400': + description: Failed to add user. + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error information. + example: getaddrinfo EAI_AGAIN mongodb + /health: + get: + summary: Check the health status of the service. + operationId: checkHealth + responses: + '200': + description: Service is healthy. + content: + application/json: + schema: + type: object + properties: + status: + type: string + description: Health status. + example: OK + /login: + post: + summary: Log in to the system. + operationId: loginUser + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: User ID. + example: student + password: + type: string + description: User password. + example: pass + responses: + '200': + description: Login successful. Returns user token, username, and creation date. + content: + application/json: + schema: + type: object + properties: + token: + type: string + description: User token. + example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NWY3NTZkYjNmYTIyZDIyN2E0YjdjN2QiLCJpYXQiOjE3MTA3MDg3NDUsImV4cCI6MTcxMDcxMjM0NX0.VMG_5DOyQ4GYlJQRcu1I6ICG1IGzuo2Xuei093ONHxw + username: + type: string + description: Username. + example: student + createdAt: + type: string + description: Creation date. + example: '2024-03-17T20:47:23.935Z' + '401': + description: Invalid credentials. + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Shows the error info.. + example: Invalid credentials + '500': + description: Internal server error. + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error information. + example: Internal Server Error \ No newline at end of file From ef1205c8b68e7b5430814a824be973255ea7de0f Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Thu, 25 Apr 2024 18:15:07 +0200 Subject: [PATCH 02/10] added update statistics --- gatewayservice/openapi.yaml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index 285e7c56..0f007900 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -141,4 +141,23 @@ paths: error: type: string description: Error information. - example: Internal Server Error \ No newline at end of file + example: Internal Server Error + /updateStats: + post: + summary: Updates the statistics. + operationId: updateStats + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: User ID. + example: student + password: + type: string + description: User password. + example: pass \ No newline at end of file From 5a2835917dc5dfc5318bd12a21ba08393c32150d Mon Sep 17 00:00:00 2001 From: carlospelazas Date: Mon, 29 Apr 2024 16:04:49 +0200 Subject: [PATCH 03/10] add swagger to gateway --- docker-compose.yml | 18 +++++++------- gatewayservice/gateway-service.js | 21 ++++++++++++++++ gatewayservice/package-lock.json | 40 ++++++++++++++++++++++++++++++- gatewayservice/package.json | 5 +++- 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d92fbcc1..ced963b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -119,15 +119,15 @@ services: GROUP_SERVICE_URL: http://groupservice:8005 MULTIPLAYER_SERVICE_URL: http://multiplayerservice:8006 - webapp: - container_name: webapp-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_en2a/webapp:latest - profiles: ["dev", "prod"] - build: ./webapp - depends_on: - - gatewayservice - ports: - - "80:80" + # webapp: + # container_name: webapp-${teamname:-defaultASW} + # image: ghcr.io/arquisoft/wiq_en2a/webapp:latest + # profiles: ["dev", "prod"] + # build: ./webapp + # depends_on: + # - gatewayservice + # ports: + # - "80:80" prometheus: image: prom/prometheus diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 6b994aa9..11014940 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -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; @@ -184,6 +189,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, () => { diff --git a/gatewayservice/package-lock.json b/gatewayservice/package-lock.json index fc5f2d60..6a1fa37f 100644 --- a/gatewayservice/package-lock.json +++ b/gatewayservice/package-lock.json @@ -12,7 +12,10 @@ "axios": "^1.6.5", "cors": "^2.8.5", "express": "^4.18.2", - "express-prom-bundle": "^7.0.0" + "express-prom-bundle": "^7.0.0", + "fs": "^0.0.1-security", + "swagger-ui-express": "^5.0.0", + "yaml": "^2.4.2" }, "devDependencies": { "jest": "^29.7.0", @@ -2264,6 +2267,11 @@ "node": ">= 0.6" } }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4389,6 +4397,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/swagger-ui-dist": { + "version": "5.17.2", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.17.2.tgz", + "integrity": "sha512-V/NqUw6QoTrjSpctp2oLQvxrl3vW29UsUtZyq7B1CF0v870KOFbYGDQw8rpKaKm0JxTwHpWnW1SN9YuKZdiCyw==" + }, + "node_modules/swagger-ui-express": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-5.0.0.tgz", + "integrity": "sha512-tsU9tODVvhyfkNSvf03E6FAk+z+5cU3lXAzMy6Pv4av2Gt2xA0++fogwC4qo19XuFf6hdxevPuVCSKFuMHJhFA==", + "dependencies": { + "swagger-ui-dist": ">=5.0.0" + }, + "engines": { + "node": ">= v0.10.32" + }, + "peerDependencies": { + "express": ">=4.0.0 || >=5.0.0-beta" + } + }, "node_modules/tdigest": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.2.tgz", @@ -4636,6 +4663,17 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, + "node_modules/yaml": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", + "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", diff --git a/gatewayservice/package.json b/gatewayservice/package.json index 715d3620..d9162e6e 100644 --- a/gatewayservice/package.json +++ b/gatewayservice/package.json @@ -21,7 +21,10 @@ "axios": "^1.6.5", "cors": "^2.8.5", "express": "^4.18.2", - "express-prom-bundle": "^7.0.0" + "express-prom-bundle": "^7.0.0", + "fs": "^0.0.1-security", + "swagger-ui-express": "^5.0.0", + "yaml": "^2.4.2" }, "devDependencies": { "jest": "^29.7.0", From 28fbe2fc6cfa94f05677c3e7ec40ed7910f876d6 Mon Sep 17 00:00:00 2001 From: carlospelazas Date: Mon, 29 Apr 2024 16:10:46 +0200 Subject: [PATCH 04/10] update postman gateway --- .../postman/Gateway.postman_collection.json | 66 +++++++++++++++++-- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/gatewayservice/postman/Gateway.postman_collection.json b/gatewayservice/postman/Gateway.postman_collection.json index f56ff326..b80620c9 100644 --- a/gatewayservice/postman/Gateway.postman_collection.json +++ b/gatewayservice/postman/Gateway.postman_collection.json @@ -13,7 +13,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"players\":[\r\n {\"uuid\":\"af4c5a65-7768-47b8-aa05-4aff34b62391\"}\r\n ]\r\n}", + "raw": "{\r\n \"players\":[\r\n {\"uuid\":\"6a63ca40-3f17-4a5d-9ed5-f756433c4bb1\"}\r\n ]\r\n}", "options": { "raw": { "language": "json" @@ -21,14 +21,15 @@ } }, "url": { - "raw": "http://localhost:8000/createGame", + "raw": "http://localhost:8000/createGame/en", "protocol": "http", "host": [ "localhost" ], "port": "8000", "path": [ - "createGame" + "createGame", + "en" ] } }, @@ -66,7 +67,19 @@ "name": "Get statistics", "request": { "method": "GET", - "header": [] + "header": [], + "url": { + "raw": "http://localhost:8000/getStats/6a63ca40-3f17-4a5d-9ed5-f756433c4bb1", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "getStats", + "6a63ca40-3f17-4a5d-9ed5-f756433c4bb1" + ] + } }, "response": [] }, @@ -77,7 +90,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"creatorUUID\": \"905aa11b-fd0c-4567-8fe4-e64dac7d96e8\",\r\n \"groupName\": \"GrupoMESSI\",\r\n \"description\": \"grupo tekila oleole\",\r\n \"isPublic\": false\r\n}", + "raw": "{\r\n \"creatorUUID\": \"7d0eef6d-9997-4388-932c-ecf6df2a1454\",\r\n \"groupName\": \"GrupoMESSI\",\r\n \"description\": \"grupo tekila oleole\",\r\n \"isPublic\": false\r\n}", "options": { "raw": { "language": "json" @@ -105,7 +118,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"uuid\": \"58cd0585-e578-4f97-bfe9-eacdaee33ddc\",\r\n \"groupName\": \"GrupoMESSI\",\r\n \"joinCode\": \"bxUs\"\r\n}", + "raw": "{\r\n \"uuid\": \"6a63ca40-3f17-4a5d-9ed5-f756433c4bb1\",\r\n \"groupName\": \"GrupoMESSI\",\r\n \"joinCode\": \"qRwL\"\r\n}", "options": { "raw": { "language": "json" @@ -178,7 +191,46 @@ "name": "Get groups", "request": { "method": "GET", - "header": [] + "header": [], + "url": { + "raw": "http://localhost:8000/getGroups", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "getGroups" + ] + } + }, + "response": [] + }, + { + "name": "Login", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"username\":\"mbappe\",\r\n \"password\": \"1234\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8000/login", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "login" + ] + } }, "response": [] } From 91d77def05d680c48d8ef91d192cb7c7808f168d Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Mon, 29 Apr 2024 16:31:19 +0200 Subject: [PATCH 05/10] Added statistics and create group --- gatewayservice/openapi.yaml | 141 ++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 7 deletions(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index 0f007900..22520f0c 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -6,7 +6,7 @@ info: servers: - url: http://localhost:8000 description: Development server - - url: http://SOMEIP:8000 + - url: http://conoceryvencer.xyz:8000 description: Production server paths: /adduser: @@ -153,11 +153,138 @@ paths: schema: type: object properties: - username: + players: + type: array + description: array with Players + items: + type: object + properties: + uuid: + type: string + description: Player ID + example: "3c68688e-84e7-4d29-b7c7-09474d42b669" + nCorrectAnswers: + type: integer + description: number of correct answers + example: 12 + nIncorrectAnswers: + type: integer + description: number of incorrect answers + example: 3 + totalScore: + type: integer + description: total score + example: 500 + isWinner: + type: boolean + description: if the player is the winner + example: true + responses: + '200': + description: Statistics updated successfully. + content: + application/json: + schema: + type: object + properties: + message: + type: string + description: Message. + example: Statistics updated successfully + '500': + description: Failed to update statistics. + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error information. + example: Failed to update statistics + + + + + + /createGroup: + post: + summary: Create a new group, given a group name, description, whether it is public, and the id of the creator + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + creatorUUID: type: string - description: User ID. - example: student - password: + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + groupName: type: string - description: User password. - example: pass \ No newline at end of file + example: "Example Group" + description: + type: string + example: "Description of the group" + isPublic: + type: boolean + example: false + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + uuid: + type: string + example: "7db83f24-eb3c-4d20-804c-3b966e084520" + groupName: + type: string + example: "Example Group" + admin: + type: string + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + members: + type: array + items: + type: string + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + maxNumUsers: + type: integer + example: 30 + description: + type: string + example: "Description of the group" + isPublic: + type: boolean + example: false + joinCode: + type: string + example: "KB8L" + creationDate: + type: string + format: date-time + example: "2024-04-29T14:17:49.000Z" + _id: + type: string + example: "662fac0d76479bb08f1a4a35" + __v: + type: integer + example: 0 + '400': + description: Bad request + '500': + description: Internal Server Error. There is already a group with that name! + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Internal Server Error" + message: + type: string + example: "There is already a group with that name!" \ No newline at end of file From 19764c34ca802d27deb3024ea4f3be4c9e885243 Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Mon, 29 Apr 2024 16:41:07 +0200 Subject: [PATCH 06/10] Added join group and create group to api --- gatewayservice/openapi.yaml | 137 ++++++++++++++++++++++++++++++++---- 1 file changed, 123 insertions(+), 14 deletions(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index 22520f0c..9811dd71 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -181,18 +181,40 @@ paths: example: true responses: '200': - description: Statistics updated successfully. + description: Player statistics updated successfully content: application/json: schema: type: object properties: - message: - type: string - description: Message. - example: Statistics updated successfully + players: + type: array + description: array with Players + items: + type: object + properties: + uuid: + type: string + description: Player ID + example: "3c68688e-84e7-4d29-b7c7-09474d42b669" + nCorrectAnswers: + type: integer + description: number of correct answers + example: 12 + nIncorrectAnswers: + type: integer + description: number of incorrect answers + example: 3 + totalScore: + type: integer + description: total score + example: 500 + isWinner: + type: boolean + description: if the player is the winner + example: true '500': - description: Failed to update statistics. + description: Internal server error content: application/json: schema: @@ -200,13 +222,22 @@ paths: properties: error: type: string - description: Error information. - example: Failed to update statistics - - - - - + example: "Internal server error" + /createGame/:lang: + post: + summary: Creates a game with the specified language. + operationId: createGame + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + player: + type: array + description: array with Players ID + example: student /createGroup: post: summary: Create a new group, given a group name, description, whether it is public, and the id of the creator @@ -287,4 +318,82 @@ paths: example: "Internal Server Error" message: type: string - example: "There is already a group with that name!" \ No newline at end of file + example: "There is already a group with that name!" + /joinGroup: + post: + summary: Join an existing group, given a group name, a join code and the id of the user to join + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + uuid: + type: string + example: "a1b50b65-e2fe-4a92-87ea-d16154c5584b" + groupName: + type: string + example: "Example Group" + joinCode: + type: string + example: "KB8L" + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + _id: + type: string + example: "662fac0d76479bb08f1a4a35" + uuid: + type: string + example: "7db83f24-eb3c-4d20-804c-3b966e084520" + groupName: + type: string + example: "Example Group" + admin: + type: string + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + members: + type: array + items: + type: string + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + maxNumUsers: + type: integer + example: 30 + description: + type: string + example: "Description of the group" + isPublic: + type: boolean + example: false + joinCode: + type: string + example: "KB8L" + creationDate: + type: string + format: date-time + example: "2024-04-29T14:17:49.000Z" + __v: + type: integer + example: 1 + '400': + description: Bad request + '500': + description: Internal Server Error. The group does not exist! + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Internal Server Error" + message: + type: string + example: "The group does not exist! \ No newline at end of file From 350ed8a7d81b7543d8f6d5df54e93f30cf8a48b2 Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Mon, 29 Apr 2024 16:43:28 +0200 Subject: [PATCH 07/10] Added get stats to the api documentation --- gatewayservice/openapi.yaml | 90 ++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index 9811dd71..e7a095f5 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -223,10 +223,17 @@ paths: error: type: string example: "Internal server error" - /createGame/:lang: + /createGame/{lang}: post: - summary: Creates a game with the specified language. - operationId: createGame + summary: Create a new game + description: This endpoint creates a new game for a list of players in a specific language. + parameters: + - in: path + name: lang + schema: + type: string + required: true + description: Language of the game requestBody: required: true content: @@ -234,10 +241,81 @@ paths: schema: type: object properties: - player: + players: type: array - description: array with Players ID - example: student + description: array with Players + items: + type: object + properties: + uuid: + type: string + description: Player ID + example: "6a63ca40-3f17-4a5d-9ed5-f756433c4bb1" + responses: + '200': + description: Game created successfully + content: + application/json: + schema: + type: object + properties: + players: + type: array + description: array with Players + items: + type: object + properties: + uuid: + type: string + description: Player ID + example: "6a63ca40-3f17-4a5d-9ed5-f756433c4bb1" + '500': + description: Internal server error + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Internal server error" + /getStats/{id}: + get: + summary: Get player statistics + description: This endpoint retrieves the statistics for a player by their ID. If the player has a last game ID, it also retrieves the questions from the last game. + parameters: + - in: path + name: id + schema: + type: string + required: true + description: Player ID + responses: + '200': + description: Player statistics retrieved successfully + content: + application/json: + schema: + type: object + properties: + userStats: + type: object + description: Player statistics + lastGame: + type: array + description: Questions from the last game + items: + type: object + '500': + description: Internal server error + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Internal server error" /createGroup: post: summary: Create a new group, given a group name, description, whether it is public, and the id of the creator From 959a62bb0ef25e864bbd7be4ea99369d5e447f9b Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Mon, 29 Apr 2024 16:49:09 +0200 Subject: [PATCH 08/10] Added last petitons to api documentation --- gatewayservice/openapi.yaml | 155 +++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index e7a095f5..5000bef2 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -474,4 +474,157 @@ paths: example: "Internal Server Error" message: type: string - example: "The group does not exist! \ No newline at end of file + example: "The group does not exist!" + /getGroup/{uuid}: + get: + summary: Get group information by UUID + parameters: + - in: path + name: uuid + required: true + schema: + type: string + description: UUID of the group to retrieve + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + _id: + type: string + example: "662fac0d76479bb08f1a4a35" + uuid: + type: string + example: "7db83f24-eb3c-4d20-804c-3b966e084520" + groupName: + type: string + example: "Example Group" + admin: + type: object + properties: + _id: + type: string + example: "6614d4be5bccd1b3f21836e0" + uuid: + type: string + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + username: + type: string + example: "juan" + nCorrectAnswers: + type: integer + example: 0 + nWrongAnswers: + type: integer + example: 0 + totalScore: + type: integer + example: 0 + nWins: + type: integer + example: 0 + createdAt: + type: string + format: date-time + example: "2024-04-09T05:40:14.820Z" + __v: + type: integer + example: 0 + groupId: + type: string + example: "7db83f24-eb3c-4d20-804c-3b966e084520" + members: + type: array + items: + type: object + properties: + _id: + type: string + example: "6614d4be5bccd1b3f21836e0" + uuid: + type: string + example: "7d0eef6d-9997-4388-932c-ecf6df2a1454" + username: + type: string + example: "juan" + nCorrectAnswers: + type: integer + example: 0 + nWrongAnswers: + type: integer + example: 0 + totalScore: + type: integer + example: 0 + nWins: + type: integer + example: 0 + createdAt: + type: string + format: date-time + example: "2024-04-09T05:40:14.820Z" + __v: + type: integer + example: 0 + groupId: + type: string + example: "7db83f24-eb3c-4d20-804c-3b966e084520" + maxNumUsers: + type: integer + example: 30 + description: + type: string + example: "Description of the group" + isPublic: + type: boolean + example: false + joinCode: + type: string + example: "KB8L" + creationDate: + type: string + format: date-time + example: "2024-04-29T14:17:49.000Z" + __v: + type: integer + example: 1 + '500': + description: Internal Server Error. There is no group with that UUID. + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Internal Server Error" + message: + type: string + example: "There is no group with that UUID." + /getGroups: + get: + summary: Get all groups + description: This endpoint retrieves all the groups. + responses: + '200': + description: Groups retrieved successfully + content: + application/json: + schema: + type: array + items: + type: object + description: Group object + '500': + description: Internal server error + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Internal server error" \ No newline at end of file From 1dffc78dde8f6cbc64be389f55d5ec05fdc21cf4 Mon Sep 17 00:00:00 2001 From: Pablo Lobeto Arenas Date: Mon, 29 Apr 2024 16:51:20 +0200 Subject: [PATCH 09/10] Fix error in get groups --- gatewayservice/openapi.yaml | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index 5000bef2..9acca3d7 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -604,7 +604,7 @@ paths: message: type: string example: "There is no group with that UUID." - /getGroups: + getGroups: get: summary: Get all groups description: This endpoint retrieves all the groups. @@ -618,6 +618,40 @@ paths: items: type: object description: Group object + properties: + _id: + type: string + example: "662aa993f1fae005e7d458b1" + uuid: + type: string + example: "25051714-b1de-4601-a834-a5c53604a31b" + groupName: + type: string + example: "12345" + admin: + type: string + example: "09d12a28-0a2d-4370-9126-730f1de57aa9" + members: + type: array + items: + type: string + example: ["09d12a28-0a2d-4370-9126-730f1de57aa9"] + maxNumUsers: + type: integer + example: 30 + description: + type: string + example: "12345" + isPublic: + type: boolean + example: true + creationDate: + type: string + format: date-time + example: "2024-04-25T19:05:55.000Z" + __v: + type: integer + example: 0 '500': description: Internal server error content: From 423ea76b90344bfc2a2b1e60a8022cc6eb84b14f Mon Sep 17 00:00:00 2001 From: carlospelazas Date: Mon, 29 Apr 2024 16:53:24 +0200 Subject: [PATCH 10/10] ready to merge --- docker-compose.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ced963b8..d92fbcc1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -119,15 +119,15 @@ services: GROUP_SERVICE_URL: http://groupservice:8005 MULTIPLAYER_SERVICE_URL: http://multiplayerservice:8006 - # webapp: - # container_name: webapp-${teamname:-defaultASW} - # image: ghcr.io/arquisoft/wiq_en2a/webapp:latest - # profiles: ["dev", "prod"] - # build: ./webapp - # depends_on: - # - gatewayservice - # ports: - # - "80:80" + webapp: + container_name: webapp-${teamname:-defaultASW} + image: ghcr.io/arquisoft/wiq_en2a/webapp:latest + profiles: ["dev", "prod"] + build: ./webapp + depends_on: + - gatewayservice + ports: + - "80:80" prometheus: image: prom/prometheus