diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index 79a2a46..e4fc0ae 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -2,23 +2,41 @@ openapi: 3.0.0 info: title: Gateway Service API version: 0.0.1 - description: Gateway Service + description: Gateway Service OpenAPI specification. servers: - url: http://localhost:8080 description: Local server paths: - /adduser: + /user/adduser: post: - summary: Add a new user + summary: Add a new user to the database + tags: + - User + description: Add a new user to the system with provided username, password, and email. operationId: addUser requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/User' + type: object + properties: + username: + type: string + description: The username of the user. + password: + type: string + description: The password of the user. + email: + type: string + format: email + description: The email address of the user. + required: + - username + - password + - email responses: '200': description: User added successfully @@ -29,11 +47,121 @@ paths: properties: username: type: string - example: User ID - password: - type: string - example: Password + description: The username of the newly created user. '400': - description: Invalid input - '409': - description: User already exists \ No newline at end of file + description: Invalid input or server error + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Error message generated by the server" + + + /user/editUser: + post: + summary: Update the stats of a user + tags: + - User + description: Edit a user in the system to update the total and correct questions answered. + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: The username of the user to be updated. + questions_answered: + type: integer + description: The number of questions answered to be added to the user's total. + correctly_answered_questions: + type: integer + description: The number of correctly answered questions to be added to the user's total. + required: + - username + - questions_answered + - correctly_answered_questions + responses: + '200': + description: User updated successfully + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: User updated + '404': + description: User not found + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: User not found + '500': + description: Internal Server Error + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: Internal Server Error + +/auth/login: + type: POST + description: Authenticate a user by providing username and password. + requestBody: + description: User credentials for authentication. + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: The username of the user. + password: + type: string + description: The password of the user. + required: + - username + - password + possibleResponses: + '200': + description: User authenticated successfully + body: + application/json: + schema: + type: object + properties: + token: + type: string + description: JWT token for accessing protected endpoints. + '401': + description: Unauthorized + body: + application/json: + schema: + type: object + properties: + error: + type: string + example: Unauthorized + + +tags: + - name: User + description: Endpoints related to user management. + - name: Authentication + description: Endpoints related to user authentication. \ No newline at end of file diff --git a/users/package-lock.json b/users/package-lock.json new file mode 100644 index 0000000..4b36dbc --- /dev/null +++ b/users/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "users", + "lockfileVersion": 2, + "requires": true, + "packages": {} +}