Skip to content
Snippets Groups Projects
spec.json 56.4 KiB
Newer Older
heikkkk's avatar
heikkkk committed
{
  "openapi": "3.0.1",
  "info": {
    "title": "Sparesti API",
    "description": "The Sparesti API",
    "version": "3.0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "security": [
    {
      "Bearer Authentication": []
    }
  ],
    {
      "name": "Item",
      "description": "Endpoints for managing store and user inventory."
    },
    {
      "name": "Friend",
      "description": "API for managing friend relationships"
    }
  ],
heikkkk's avatar
heikkkk committed
  "paths": {
    "/api/users/subscription/{subscriptionLevel}": {
      "put": {
        "tags": [
          "User"
        ],
        "summary": "Update User Subscription Level",
        "description": "Updates the subscription level of the current user",
        "operationId": "updateSubscriptionLevel",
        "parameters": [
          {
            "name": "subscriptionLevel",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Subscription level updated successfully",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/friends/{friendId}": {
      "put": {
        "tags": [
          "Friend"
        ],
        "summary": "Accept a friend request",
        "description": "Accepts a friend request from another user.",
        "operationId": "acceptFriendRequest",
        "parameters": [
          {
            "name": "friendId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "404": {
            "description": "Friend request not found",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "200": {
            "description": "Friend request successfully accepted",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Friend"
        ],
        "summary": "Delete a friend or cancel a friend request",
        "description": "Deletes an existing friend from your friend list or cancels a received friend request.",
        "operationId": "deleteFriendOrFriendRequest",
        "parameters": [
          {
            "name": "friendId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "404": {
            "description": "Friend or friend request not found",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "200": {
            "description": "Friend successfully deleted or friend request cancelled",
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
heikkkk's avatar
heikkkk committed
    "/bank/v1/transaction/norwegian-domestic-payment-to-self": {
      "post": {
        "tags": [
          "transaction-controller"
        ],
        "summary": "Transfer to account",
        "description": "Transfer money from a users account to another account of the same user",
        "operationId": "transferToSelf",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "404": {
            "description": "Bank profile id does not exist",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionDTO"
                }
              }
            }
          },
          "200": {
            "description": "No accounts associated with a bank user",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionDTO"
                }
              }
            }
          }
        }
      }
    },
    "/bank/v1/profile/create-profile": {
      "post": {
        "tags": [
          "bank-profile-controller"
        ],
        "summary": "Create bank profile",
        "description": "Create a bank profile by providing a social security number",
        "operationId": "createBankProfile",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BankProfileDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "400": {
            "description": "Could not create profile",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/BankProfileResponseDTO"
                }
              }
            }
          },
          "200": {
            "description": "Successfully created a bank profile",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/BankProfileResponseDTO"
                }
              }
            }
          }
        }
      }
    },
    "/bank/v1/account/create-account": {
      "post": {
        "tags": [
          "account-controller"
        ],
        "summary": "Create account",
        "description": "Create account with random balance",
        "operationId": "createAccount",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "404": {
            "description": "Provided bank profile id could not be found",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponseDTO"
                }
              }
            }
          },
          "200": {
            "description": "Successfully created account",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponseDTO"
                }
              }
            }
          }
        }
      }
    },
    "/api/users/send-feedback": {
      "post": {
        "tags": [
          "User"
        ],
        "summary": "Send feedback",
        "description": "Send feedback from an email.",
        "operationId": "sendFeedback",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
heikkkk's avatar
heikkkk committed
    "/api/users/reset-password": {
      "post": {
        "tags": [
          "User"
        ],
        "summary": "Initiate a password reset",
        "description": "Send a password reset mail to the user with the specified email",
        "operationId": "resetPassword",
        "requestBody": {
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Successfully initiated a password reset"
          }
        },
        "security": []
      }
    },
    "/api/users/confirm-password": {
      "post": {
        "tags": [
          "User"
        ],
        "summary": "Confirm a password reset",
        "description": "Confirms a password reset using a token and a new password",
        "operationId": "confirmPasswordReset",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasswordResetDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "403": {
            "description": "Invalid token"
          },
          "204": {
            "description": "Password was reset successfully"
heikkkk's avatar
heikkkk committed
          }
        },
        "security": []
      }
    },
    "/api/item/{itemId}": {
      "post": {
        "tags": [
          "Item"
        ],
        "summary": "Purchase an item",
        "description": "Performs a purchase of the item by the user. Points will be deducted from the user.",
        "operationId": "buyItem",
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "403": {
            "description": "Insufficient points to purchase the item",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "201": {
            "description": "Item purchased and added to inventory successfully",
            "content": {
              "application/json": {

              }
            }
          }
        }
      }
    },
heikkkk's avatar
heikkkk committed
      "post": {
        "tags": [
          "Image"
        ],
        "summary": "Upload an image",
        "description": "Upload an image to the server",
        "operationId": "uploadImage",
        "requestBody": {
          "content": {
            "multipart/form-data": {
heikkkk's avatar
heikkkk committed
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
            "description": "Successfully uploaded the image",
            "content": {
              "*/*": {
                "schema": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
heikkkk's avatar
heikkkk committed
          }
        }
      }
    },
    "/api/goals": {
      "get": {
        "tags": [
          "Goal"
        ],
        "summary": "Get goals",
        "description": "Get the goals of the authenticated user",
        "operationId": "getGoals",
        "responses": {
          "200": {
            "description": "Successfully retrieved the goals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GoalDTO"
                  }
                }
              }
            }
          }
        }
      },
heikkkk's avatar
heikkkk committed
      "post": {
        "tags": [
          "Goal"
heikkkk's avatar
heikkkk committed
        ],
        "summary": "Create a goal",
        "description": "Create a new goal",
heikkkk's avatar
heikkkk committed
        "operationId": "createGoal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateGoalDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successfully created a goal",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
heikkkk's avatar
heikkkk committed
                "schema": {
                  "$ref": "#/components/schemas/GoalDTO"
                }
              }
            }
          }
        }
      }
    },
    "/api/goals/update-challenge": {
      "post": {
        "tags": [
          "Goal"
        ],
        "summary": "Update a challenge",
        "description": "Update a challenge day as completed",
        "operationId": "updateChallenge",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkChallengeDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "401": {
            "description": "Day is already completed or day outside of range",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionResponse"
                }
              }
            }
          },
          "200": {
            "description": "Successfully updated the challenge"
          }
        }
      }
    },
    "/api/goals/update-challenge-amount": {
      "post": {
        "tags": [
          "Goal"
        ],
        "summary": "Update challenge saving amount",
        "description": "Update the challenge saving amount",
        "operationId": "updateChallengeAmount",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkChallengeDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully updated the challenge"
          }
        }
      }
    },
    "/api/friends/{userId}": {
      "post": {
        "tags": [
          "Friend"
        ],
        "summary": "Send a friend request",
        "description": "Sends a new friend request to another user.",
        "operationId": "addFriendRequest",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Friend request successfully created"
          }
        }
      }
    },
Henrik's avatar
Henrik committed
    "/api/budget/update/{budgetId}": {
heikkkk's avatar
heikkkk committed
      "post": {
        "tags": [
          "User"
        ],
        "summary": "Updates a budget",
        "description": "Updates a budget based on the budget request",
        "operationId": "updateBudget",
Henrik's avatar
Henrik committed
        "parameters": [
          {
            "name": "budgetId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
heikkkk's avatar
heikkkk committed
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
Henrik's avatar
Henrik committed
                "$ref": "#/components/schemas/BudgetRequestDTO"
heikkkk's avatar
heikkkk committed
              }
            }
          },
          "required": true
        },
        "responses": {
          "500": {
            "description": "Budget is not found",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "200": {
            "description": "Successfully updated budget",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/budget/update/expense/{budgetId}": {
      "post": {
        "tags": [
          "User"
        ],
        "summary": "Created/Updates an expense",
        "description": "Creates/Updates a budget based on the budget request",
        "operationId": "updateExpense",
        "parameters": [
          {
            "name": "budgetId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExpenseRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "500": {
            "description": "Error updating expense",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "200": {
            "description": "Successfully updated budget",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/budget/create": {
      "post": {
        "tags": [
          "User"
        ],
        "summary": "Create a new budget",
        "description": "Create a new budget with based on the budget request",
        "operationId": "createBudget",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BudgetRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully created new budget",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
heikkkk's avatar
heikkkk committed
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/valid-email/{email}": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Validate email",
        "description": "Check that the given email is valid",
        "operationId": "validateEmail",
        "parameters": [
          {
            "name": "email",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "409": {
            "description": "Email already exists",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionResponse"
heikkkk's avatar
heikkkk committed
                }
              }
            }
          },
          "200": {
            "description": "Email is valid",
heikkkk's avatar
heikkkk committed
            "content": {
              "*/*": {
                "schema": {
                  "type": "object"
heikkkk's avatar
heikkkk committed
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/auth/signup": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "User Signup",
        "description": "Sign up a new user",
        "operationId": "signup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignUpRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "409": {
            "description": "Email already exists",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionResponse"
heikkkk's avatar
heikkkk committed
                }
              }
            }
          },
          "201": {
            "description": "Successfully signed up",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationResponse"
heikkkk's avatar
heikkkk committed
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/auth/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "User Login",
        "description": "Log in with an existing user",
        "operationId": "login",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully logged in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid credentials",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionResponse"
                }
              }
            }
          },
          "404": {
            "description": "User not found",
heikkkk's avatar
heikkkk committed
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionResponse"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/users": {
      "patch": {
        "tags": [
          "User"
        ],
        "summary": "Update a profile",
        "description": "Update the profile of the authenticated user",
        "operationId": "update",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserUpdateDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully updated profile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserDTO"
                }
              }
            }
          }
        }
      }
    },
    "/api/users/update-account": {
      "patch": {
        "tags": [
          "User"
        ],
        "summary": "Update a user's bank account",
        "description": "Changes either a user's checking account or savings account",
        "operationId": "selectBankAccount",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BankAccountDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          }
        }
      }
    },
    "/api/users/password": {
      "patch": {
        "tags": [
          "User"
        ],
        "summary": "Update a password",
        "description": "Update the password of the authenticated user",
        "operationId": "updatePassword",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasswordUpdateDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully updated password",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/UserDTO"
                }
              }
            }
          }
        }
      }
    },
heikkkk's avatar
heikkkk committed
    "/bank/v1/account/accounts/ssn/{ssn}": {
      "get": {
        "tags": [
          "account-controller"
        ],
        "summary": "Get user accounts",
        "description": "Get accounts associated with a user by providing their social security number",
        "operationId": "getAccountsBySsn",
        "parameters": [
          {
            "name": "ssn",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "No accounts associated with a bank user",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Account"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Social security number does not exist",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Account"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/bank/v1/account/accounts/profile/{bankProfileId}": {
      "get": {
        "tags": [
          "account-controller"