{ "openapi": "3.0.2", "info": { "title": "IFN666 A3 API", "description": "This is a simple Express API for managing categories and transactions in budget manager application.", "version": "1.0.0", "contact": { "email": "N11428911@qut.edu.au" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "paths": { "/api/category/{User_ID}": { "get": { "summary": "List categories", "description": "Retrieves a list of categories for the specified user.", "parameters": [ { "name": "User_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "categories": { "type": "array", "items": { "type": "object", "properties": { "ID": { "type": "integer" }, "name": { "type": "string" } } } } } } } } } } } }, "/api/transaction/summarybyyearmonth/{User_ID}": { "get": { "summary": "Get transaction summary by year and month", "description": "Retrieves a summary of transactions by year and month for the specified user.", "parameters": [ { "name": "User_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "summary": { "type": "array", "items": { "type": "object", "properties": { "user_id": { "type": "integer" }, "amount": { "type": "number" }, "year": { "type": "integer" }, "month": { "type": "integer" } } } } } } } } } } } }, "/api/transaction/summarybycategory/{User_ID}": { "get": { "summary": "Get transaction summary by category", "description": "Retrieves a summary of transactions by category for the specified user.", "parameters": [ { "name": "User_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "summary": { "type": "array", "items": { "type": "object", "properties": { "user_id": { "type": "integer" }, "category": { "type": "string" }, "amount": { "type": "number" }, "year": { "type": "integer" }, "month": { "type": "integer" } } } } } } } } } } } }, "/api/transaction/{User_ID}": { "get": { "summary": "List transactions", "description": "Retrieves a list of transactions for the specified user.", "parameters": [ { "name": "User_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "transactions": { "type": "array", "items": { "type": "object", "properties": { "ID": { "type": "integer" }, "amount": { "type": "number" }, "note": { "type": "string" }, "user_id": { "type": "integer" }, "date": { "type": "string", "format": "date" }, "category": { "type": "string" } } } } } } } } } } } }, "/api/category/create": { "post": { "summary": "Create category", "description": "Creates a new category for the user.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "user_id": { "type": "integer" } } } } } }, "responses": { "201": { "description": "Data inserted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "message": { "type": "string" } } } } } } } } }, "/api/categories/initial": { "post": { "summary": "Create initial categories", "description": "Creates initial set of categories for the user.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "user_id": { "type": "integer" } } } } } }, "responses": { "201": { "description": "Data inserted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "message": { "type": "string" } } } } } } } } }, "/api/transaction/create": { "post": { "summary": "Create transaction", "description": "Creates a new transaction for the user.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "amount": { "type": "number" }, "note": { "type": "string" }, "user_id": { "type": "integer" }, "date": { "type": "string", "format": "date" }, "category": { "type": "string" } } } } } }, "responses": { "201": { "description": "Data inserted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "message": { "type": "string" } } } } } } } } }, "/api/category/modify/{Category_ID}": { "put": { "summary": "Modify category", "description": "Modifies an existing category for the user.", "parameters": [ { "name": "Category_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" } } } } } }, "responses": { "200": { "description": "Category updated successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string" } } } } } }, "404": { "description": "Category not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } } }, "500": { "description": "Internal server error", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } } } } } }, "/api/transaction/modify/{Transaction_ID}": { "put": { "summary": "Modify transaction", "description": "Modifies an existing transaction for the user.", "parameters": [ { "name": "Transaction_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "amount": { "type": "number" }, "note": { "type": "string" }, "date": { "type": "string", "format": "date" }, "category": { "type": "string" } } } } } }, "responses": { "200": { "description": "Transaction updated successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "message": { "type": "string" } } } } } } } } }, "/api/category/delete/{Category_ID}": { "delete": { "summary": "Delete category", "description": "Deletes an existing category for the user.", "parameters": [ { "name": "Category_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "Category deleted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "message": { "type": "string" } } } } } } } } }, "/api/transaction/delete/{Transaction_ID}": { "delete": { "summary": "Delete transaction", "description": "Deletes an existing transaction for the user.", "parameters": [ { "name": "Transaction_ID", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "Transaction deleted successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean" }, "message": { "type": "string" } } } } } } } } }, "/users/register": { "post": { "summary": "User registration", "description": "Registers a new user.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["username", "password"] } } } }, "responses": { "201": { "description": "User created successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } }, "400": { "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } }, "409": { "description": "Conflict - User already exists", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } }, "500": { "description": "Internal server error", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } } } } }, "/users/login": { "post": { "summary": "User login", "description": "Logs in an existing user.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["username", "password"] } } } }, "responses": { "200": { "description": "Successful login", "content": { "application/json": { "schema": { "type": "object", "properties": { "token_type": { "type": "string", "enum": ["Bearer"] }, "token": { "type": "string" }, "expires_in": { "type": "integer", "description": "Token expiry time in seconds" } } } } } }, "400": { "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } }, "404": { "description": "User not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } }, "401": { "description": "Unauthorized - Incorrect password", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "boolean", "enum": [true] }, "message": { "type": "string" } } } } } } } } } } }