897 lines
25 KiB
JSON
897 lines
25 KiB
JSON
{
|
|
"openapi": "3.0.0",
|
|
"info": {
|
|
"title": "DevSpace API",
|
|
"description": "API for DevSpace",
|
|
"version": "0.1.0"
|
|
},
|
|
"components": {
|
|
"securitySchemes": {
|
|
"bearerAuth": {
|
|
"type": "http",
|
|
"scheme": "bearer",
|
|
"bearerFormat": "JWT"
|
|
}
|
|
},
|
|
"schemas": {
|
|
"Post": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "Post ID"
|
|
},
|
|
"title": {
|
|
"type": "string",
|
|
"description": "Post title"
|
|
},
|
|
"content": {
|
|
"type": "string",
|
|
"description": "Post content"
|
|
},
|
|
"createdAt": {
|
|
"type": "string",
|
|
"description": "Post creation date"
|
|
},
|
|
"createdBy": {
|
|
"$ref": "#/components/schemas/User"
|
|
},
|
|
"likedBy": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/User"
|
|
}
|
|
},
|
|
"comments": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Comment"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"Comment": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "Comment ID"
|
|
},
|
|
"content": {
|
|
"type": "string",
|
|
"description": "Comment content"
|
|
},
|
|
"createdAt": {
|
|
"type": "string",
|
|
"description": "Comment creation date"
|
|
},
|
|
"createdBy": {
|
|
"$ref": "#/components/schemas/User"
|
|
},
|
|
"likedBy": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/User"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"Notification": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "Notification ID"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"description": "Notification message"
|
|
},
|
|
"timeStamp": {
|
|
"type": "string",
|
|
"description": "Notification creation date"
|
|
},
|
|
"seen": {
|
|
"type": "boolean",
|
|
"description": "Notification seen status"
|
|
}
|
|
}
|
|
},
|
|
"User": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "User ID"
|
|
},
|
|
"firstName": {
|
|
"type": "string",
|
|
"description": "User first name"
|
|
},
|
|
"isPrivate": {
|
|
"type": "boolean",
|
|
"description": "User private status"
|
|
},
|
|
"profilePictureId": {
|
|
"type": "string",
|
|
"description": "User profile picture ID"
|
|
},
|
|
"lastName": {
|
|
"type": "string",
|
|
"description": "User last name"
|
|
}
|
|
}
|
|
},
|
|
"UserWithRelations": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/components/schemas/User"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"posts": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
},
|
|
"comments": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Comment"
|
|
}
|
|
},
|
|
"followed": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/User"
|
|
}
|
|
},
|
|
"followers": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/User"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"UserWithRelationsAndNotifications": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/components/schemas/UserWithRelations"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"notifications": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Notification"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"paths": {
|
|
"/auth/signup": {
|
|
"post": {
|
|
"tags": ["Authentication"],
|
|
"summary": "Sign up a new user",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"description": "The email of the user"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"description": "The password of the user"
|
|
},
|
|
"passwordValidation": {
|
|
"type": "string",
|
|
"description": "Password validation field"
|
|
},
|
|
"firstName": {
|
|
"type": "string",
|
|
"description": "The first name of the user"
|
|
},
|
|
"lastName": {
|
|
"type": "string",
|
|
"description": "The last name of the user"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully signed up the user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/User"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid input or user already exists"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/login": {
|
|
"post": {
|
|
"tags": ["Authentication"],
|
|
"summary": "Log in a user",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"description": "The email of the user"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"description": "The password of the user"
|
|
},
|
|
"longExpiration": {
|
|
"type": "boolean",
|
|
"description": "Whether to keep the user logged in for a long time"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully logged in the user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"status": {
|
|
"type": "string",
|
|
"example": "success"
|
|
},
|
|
"token": {
|
|
"type": "string",
|
|
"description": "The JWT token for the user"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Missing email or password"
|
|
},
|
|
"401": {
|
|
"description": "Incorrect email or password"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/auth/logout": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Authentication"],
|
|
"summary": "Log out the user",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully logged out the user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"status": {
|
|
"type": "string",
|
|
"example": "success"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/posts": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "getAllPosts",
|
|
"summary": "Get all posts",
|
|
"responses": {
|
|
"200": {
|
|
"description": "A list of all posts",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "createPost",
|
|
"summary": "Create a post",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"title": {
|
|
"type": "string",
|
|
"description": "Post title"
|
|
},
|
|
"content": {
|
|
"type": "string",
|
|
"description": "Post content"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"201": {
|
|
"description": "A post",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Title and content are required"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/posts/{id}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "getPost",
|
|
"summary": "Get a post by ID",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the post",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "A post",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID"
|
|
},
|
|
"404": {
|
|
"description": "No post found with that ID"
|
|
}
|
|
}
|
|
},
|
|
"patch": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "updatePost",
|
|
"summary": "Update a post by ID",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the post",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"title": {
|
|
"type": "string",
|
|
"description": "Post title"
|
|
},
|
|
"content": {
|
|
"type": "string",
|
|
"description": "Post content"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "A post",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID or Title and content are required"
|
|
},
|
|
"404": {
|
|
"description": "No post found with that ID"
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "deletePost",
|
|
"summary": "Delete a post by ID",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the post",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"204": {
|
|
"description": "No content"
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID"
|
|
},
|
|
"404": {
|
|
"description": "No post found with that ID"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/posts/followed": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "getFollowedPosts",
|
|
"summary": "Get posts of followed users",
|
|
"responses": {
|
|
"200": {
|
|
"description": "A list of posts",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/posts/{id}/like": {
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "likePost",
|
|
"summary": "Like a post by ID",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the post",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "A post",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID or You have already liked this post"
|
|
},
|
|
"404": {
|
|
"description": "No post found with that ID"
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "unlikePost",
|
|
"summary": "Unlike a post by ID",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the post",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "A post",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Post"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID or You have not liked this post"
|
|
},
|
|
"404": {
|
|
"description": "No post found with that ID"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/posts/{id}/comment": {
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Posts"],
|
|
"operationId": "commentPost",
|
|
"summary": "Comment on a post by ID",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the post",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"content": {
|
|
"type": "string",
|
|
"description": "Comment content"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"201": {
|
|
"description": "A comment",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Comment"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid Request"
|
|
},
|
|
"404": {
|
|
"description": "No post found with that ID"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/users": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Users"],
|
|
"summary": "Get all users",
|
|
"responses": {
|
|
"200": {
|
|
"description": "A list of all users",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/User"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/users/{id}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Users"],
|
|
"summary": "Get a single user",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"description": "ID of the user",
|
|
"schema": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "A single user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserWithRelations"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/users/me": {
|
|
"get": {
|
|
"tags": ["Users"],
|
|
"summary": "Get the currently logged in user",
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "The currently logged in user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserWithRelationsAndNotifications"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"patch": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Users"],
|
|
"summary": "Update the currently logged in user",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"isPrivate": {
|
|
"type": "boolean",
|
|
"description": "Whether the user's account is private"
|
|
},
|
|
"profilePictureId": {
|
|
"type": "string",
|
|
"description": "The ID of the user's profile picture"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully updated the user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserWithRelationsAndNotifications"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid request body"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/users/follow/{id}": {
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Users"],
|
|
"summary": "Follow a user",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer",
|
|
"description": "The ID of the user to follow"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully followed the user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserWithRelations"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID"
|
|
},
|
|
"404": {
|
|
"description": "No user found with that ID"
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"bearerAuth": []
|
|
}
|
|
],
|
|
"tags": ["Users"],
|
|
"summary": "Unfollow a user",
|
|
"parameters": [
|
|
{
|
|
"in": "path",
|
|
"name": "id",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "integer",
|
|
"description": "The ID of the user to unfollow"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successfully unfollowed the user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserWithRelations"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Invalid ID"
|
|
},
|
|
"404": {
|
|
"description": "No user found with that ID"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": []
|
|
} |