Skip to content
Snippets Groups Projects
Commit c4fd86c7 authored by Felipe D'Abrantes's avatar Felipe D'Abrantes
Browse files

Upload API Contracts

parent c599b485
No related branches found
No related tags found
1 merge request!34Prepare for submission
---
openapi: 3.0.0
info:
title: "Comment Service API"
description: "API which allows users to write and like comments"
version: 1.0.0
servers:
- url: "http://localhost:8000"
paths:
/comment/{postID}:
get:
summary:
Retrives list of comments from the post ID
description:
Retrieves a list of comments
tags:
- Fetching Comments
security:
- JWT: []
parameters:
- name: postID
in: path
description: IDs of users to get
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CommentResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/comment/new:
post:
summary:
-Creates a new comment under a post
tags:
-Creating a new comment
security:
- JWT: []
requestBody:
- required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCommentRequest'
responses:
'201':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CommentResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/comment/like:
post:
summary:
-Likes a comment for a user
tags:
-Likes a comment
security:
- JWT: []
requestBody:
- required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LikeComment'
responses:
'201':
description: OK
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/comment/unlike:
post:
summary:
-Unlikes a comment for a user
tags:
-Unikes a comment
security:
- JWT: []
requestBody:
- required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UnlikeComment'
responses:
'201':
description: OK
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/comment/:
delete:
summary: Deletes a comment
security:
- JWT: []
requestBody:
description: commentId which needs to be deleted
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteComment'
responses:
'200':
description: Comment Deleted
'400':
description: Bad request. Missing required fields.
'404':
description: Comment not found
'500':
description: Internal server error
components:
securitySchemes:
JWT:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
CommentResponse:
type: object
properties:
_id:
type: string
AuthorId:
type: string
PostId:
type: string
Content:
type: string
LikerIds:
type: array
items:
type: integer
IsPostAuthor:
type: boolean
__v:
type: integer
required:
- _id
- AuthorId
- PostId
- Content
-LikerIds
-IsPostAuthor
CreateCommentRequest:
type: object
properties:
postId:
type: string
userId:
type: string
Content:
type: string
required:
- postId
- userId
- content
LikeComment:
type: object
properties:
commentId:
type: string
userId:
type: string
required:
- commentId
- userId
UnlikeComment:
type: object
properties:
commentId:
type: string
userId:
type: string
required:
- commentId
- userId
DeleteComment:
type: object
properties:
commentId:
type: string
userId:
type: string
required:
- commentId
- userId
\ No newline at end of file
openapi: "3.0.0"
info:
title: "Feed API"
description: "API for managing user dailies"
version: "1.0.0"
servers:
- url: "http://feed-service:9000"
paths:
/daily/create:
post:
summary:
Create a new user daily.
tags:
- Creating a Daily
security:
- JWT: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateDailyRequest'
responses:
'201':
description: Daily successfully created
content:
application/json:
schema:
$ref: '#/components/schemas/DailyResponse'
'400':
description: Bad request.
'401':
description: Unauthorized request.
'500':
description: Internal server error
/user/dailies:
get:
summary: Fetch the user's dailies.
tags:
- User Dailies
security:
- JWT: []
parameters:
- name: user_id
in: path
description: ID of the user whose dailies to fetch
required: true
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DailyResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/user/currentDaily:
get:
summary: Fetch the user's current daily.
tags:
- User Dailies
security:
- JWT: []
parameters:
- name: user_id
in: path
description: ID of the user whose daily to fetch
required: true
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/DailyResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/feed:
get:
summary:
Fetch a user's feed.
description:
Fetch the posts of all the user's friends.
tags:
- Fetching a User's Feed
security:
- JWT: []
parameters:
- name: user_id
in: path
description: ID of the user whose daily to fetch
required: true
schema:
type: integer
- name: question_id
in: path
description: ID of the question whose daily to fetch
required: true
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/FeedResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'500':
description: Internal server error
/daily/like:
post:
summary:
Like a daily.
tags:
- Liking a Daily
security:
- JWT: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LikeDailyRequest'
responses:
'201':
description: Daily successfully liked.
'400':
description: Bad request.
'401':
description: Unauthorized request.
'500':
description: Internal server error
/daily/unlike:
post:
summary:
Unlike a daily.
tags:
- Liking a Daily
security:
- JWT: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LikeDailyRequest'
responses:
'201':
description: Daily successfully unliked.
'400':
description: Bad request.
'401':
description: Unauthorized request.
'500':
description: Internal server error
components:
securitySchemes:
JWT:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
CreateDailyRequest:
type: object
properties:
user_id:
type: string
question_id:
type: string
content:
type: string
required:
- user_id
- question_id
- content
LikeDailyRequest:
type: object
properties:
daily_id:
type: string
user_id:
type: string
required:
- daily_id
- user_id
DailyResponse:
type: object
properties:
_id:
type: string
user_id:
type: string
question_id:
type: string
content:
type: string
users_liked:
type: array
items:
type: integer
created_at:
type: string
format: date-time
required:
- _id
- user_id
- question_id
- users_liked
- created_at
FeedResponse:
type: object
properties:
userDaily:
$ref: '#/components/schemas/DailyResponse'
feed:
type: array
items:
$ref: '#/components/schemas/DailyResponse'
\ No newline at end of file
openapi: "3.0.0"
info:
title: "Friends API"
description: "API for managing user's friends"
version: "1.0.0"
servers:
- url: "http://localhost:8000"
paths:
/friends:
get:
summary:
Get user's friends.
description:
Retrieves a list of the IDs of the user's friends.
tags:
- Getting User's Friends
security:
- JWT: []
parameters:
- name: user_id
in: query
description: ID of the user whose friends to retrieve
required: true
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
type: integer
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
delete:
summary:
Remove a friend
description:
Removes a friend from the user's friend list.
tags:
- Removing Friend
security:
- JWT: []
parameters:
- name: user_id
in: path
description: ID of the user
required: true
schema:
type: integer
- name: friend_id
in: path
description: ID of the user to unfriend
required: true
schema:
type: integer
responses:
'200':
description: OK
'400':
description: Bad Request
'404':
description: Not Found
'500':
description: Internal server error
/friends/requests:
get:
summary:
Fetch all friend requests for a user.
description:
Retrieves a list of the IDs of the friend requests the user has received.
tags:
- Friend Requests
security:
- JWT: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
type: integer
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
post:
summary:
Create a friend request.
tags:
- Friend Requests
security:
- JWT: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ManageFriendRequestRequest'
responses:
'201':
description: Created
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/friends/requests/accept:
put:
summary:
Accept a friend request.
tags:
- Managing Friend Requests
security:
- JWT: []
parameters:
- name: request_id
in: path
description: The ID of the friend request.
required: true
schema:
type: string
responses:
'201':
description: Updated
'400':
description: Bad request
'401':
description: Unauthorized
'404':
description: Not Found
'500':
description: Internal server error
/friends/requests/reject:
put:
summary:
Reject a friend request.
tags:
- Managing Friend Requests
security:
- JWT: []
parameters:
- name: request_id
in: path
description: The ID of the friend request.
required: true
schema:
type: string
responses:
'201':
description: Updated
'400':
description: Bad request
'401':
description: Unauthorized
'404':
description: Not Found
'500':
description: Internal server error
components:
securitySchemes:
JWT:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
ManageFriendRequestRequest:
type: object
description: Request object for creating/accepting/rejecting a friend request.
properties:
requester_id:
type: string
description: The ID of the user who is initiating the friend request.
receiver_id:
type: string
description: The ID of the user who is receiving the friend request.
required:
- requester_id
- receiver_id
openapi: "3.0.0"
info:
title: "Question Service"
description: "API for managing daily questions"
version: "1.0.0"
servers:
- url: "http://question-service:9000"
paths:
/question:
get:
summary:
Retrieve the daily question.
tags:
- Fetching Daily Question
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/QuestionResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/questions:
get:
summary:
Retrieve the raw questions.
tags:
- Raw Questions
security:
- JWT: []
responses:
'200':
description: OK
content:
application/json:
schema:
items:
$ref: '#/components/schemas/QuestionResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/insertQuestion:
post:
summary:
Create a new question.
description:
Allows admins to submit a new question.
tags:
- Raw Questions
security:
- JWT: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateQuestionRequest'
responses:
'201':
description: Question successfully created
'400':
description: Bad request
'401':
description: Unauthorized request
'403':
description: Forbidden
'500':
description: Internal server error
/disableQuestion:
post:
summary:
Disables a question.
description:
Allows admins to disable a raw question.
tags:
- Raw Questions
security:
- JWT: []
parameters:
- name: question_id
in: path
description: ID of the question to disable
required: true
schema:
type: string
responses:
'201':
description: Question successfully disabled
'400':
description: Bad request
'401':
description: Unauthorized request
'403':
description: Forbidden
'500':
description: Internal server error
components:
securitySchemes:
JWT:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
CreateQuestionRequest:
type: object
properties:
question:
type: string
required:
- question
DailyQuestionResponse:
type: object
properties:
_id:
type: integer
question_id:
type: integer
question_text:
type: string
format: object
next_question_at:
type: string
format: date-time
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
required:
- _id
- question_id
- question_text
- next_question_at
- created_at
- updated_at
QuestionResponse:
type: object
properties:
_id:
type: string
content:
type: string
format: object
used:
type: integer
disabled:
type: boolean
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
required:
- _id
- content
- used
- disabled
- created_at
- updated_at
openapi: "3.0.0"
info:
title: "User Service API"
description: "API for querying users"
version: "1.0.0"
servers:
- url: "http://localhost:8000"
paths:
/userlist:
post:
summary:
Retrieve a list of user objects from a list of user id's
description:
Retrieves a list of users
tags:
- Fetching Users
security:
- JWT: []
parameters:
- name: user_ids
in: query
description: IDs of users to get
schema:
type: array
items:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/UserResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/user/{username}:
get:
summary:
Profile information such as name (first, last), email.
description:
Retrieves information of user
tags:
- Fetching Users
security:
- JWT: []
parameters:
- name: user_ids
in: query
description: profile information
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/UserResponse'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/register:
post:
summary:
Creates a new user.
tags:
- Creating a User
security:
- JWT: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserRequest'
responses:
'201':
description: User successfully created
content:
application/json:
schema:
$ref: '#/components/schemas/UserResponse'
'400':
description: Bad request.
'401':
description: Unauthorized request.
'409':
description: Conflict. A user with the same email or username already exists.
/search:
get:
summary:
Search users by username or name (first or last)
description:
Retrieves a list of users whose username/first name/last name start with the given string.
tags:
- Fetching Users
security:
- JWT: []
parameters:
- name: Username or Name
in: query
description: The username query.
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/UserResponse2'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal server error
/updateuser:
put:
summary: Update information of existing user.
tags:
- Editing a User
security:
- JWT: []
parameters:
- name: user_id
in: path
description: ID of the user to update
required: true
schema:
type: integer
requestBody:
description: User object that needs to be updated
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EditUserRequest'
responses:
'200':
description: User updated successfully
'400':
description: Bad request. User input is invalid or missing required fields.
'404':
description: User not found
'500':
description: Internal server error
/login:
post:
summary:
Login a user and return a JWT token.
description:
Logs in a user and returns a JWT token for authorization.
tags:
- Login
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- username
- password
properties:
username:
type: string
description: The user's username.
password:
type: string
description: The user's password.
format: password
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
token:
type: string
description: The JWT token to use for authorization.
user:
$ref: '#/components/schemas/UserResponse'
'401':
description: Unauthorized
'500':
description: Internal server error
components:
securitySchemes:
JWT:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
CreateUserRequest:
type: object
properties:
email:
type: string
format: email
username:
type: string
password:
type: string
first_name:
type: string
last_name:
type: string
about:
type: string
profile_pic:
type: string
format: binary
required:
- email
- username
- password
EditUserRequest:
type: object
properties:
email:
type: string
format: email
first_name:
type: string
last_name:
type: string
about:
type: string
profile_pic:
type: string
format: binary
UserResponse:
type: object
properties:
_id:
type: string
email:
type: string
format: email
username:
type: string
first_name:
type: string
last_name:
type: string
about:
type: string
profile_pic:
type: string
format: binary
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
required:
- _id
- email
- username
- first_name
- last_name
- created_at
- updated_at
UserResponse2:
type: object
properties:
_id:
type: string
username:
type: string
admin:
type: boolean
profile:
type: string
__v:
type: integer
required:
- _id
- username
- admin
- profile
- __v
- created_at
- updated_at
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment