Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open api usermanagment #155

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 139 additions & 11 deletions gatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
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.
6 changes: 6 additions & 0 deletions users/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading