API/swagger.json
{ "swagger": "2.0", "info": { "description": "Banka is a light-weight core banking application that powers banking operations like account creation, customer deposit and withdrawals.", "version": "1.0.0", "title": "Banka API", "termsOfService": "http://swagger.io/terms/", "contact": { "email": "tejumoladavid@gmail.com" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "localhost:7888", "basePath": "/api/v1", "tags": [ { "name": "Users", "description": "API Endpoints for users in the system" }, { "name": "Accounts", "description": "API Endpoints for Bank Accounts in the system" }, { "name": "Transactions", "description": "API Endpoints for Credit & Debit Transactions" } ], "schemes": [ "https", "http" ], "paths": { "/auth/signup": { "post": { "tags": [ "Users" ], "summary": "Registers a new user in the app", "description": "", "operationId": "signupUser", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "body", "name": "body", "description": "User object that needs to be registered in the app", "required": true, "schema": { "$ref": "#/definitions/User" } } ], "responses": { "400": { "description": " A User with an email address already exist" }, "201": { "description": "Account was successfully created" } } } }, "/auth/create/staff": { "post": { "tags": [ "Users" ], "summary": "Registers a new staff", "description": "", "operationId": "registerStaff", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "body", "name": "body", "description": "Created an admin the app", "required": true, "schema": { "$ref": "#/definitions/Staff" } } ], "responses": { "400": { "description": " A User with an email address already exist" }, "201": { "description": "Account was successfully created" } }, "security": [ { "bearerAuth": [] } ] } }, "/auth/signin": { "post": { "tags": [ "Users" ], "summary": "Login with existing credentials", "description": "", "operationId": "loginUser", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "body", "name": "body", "description": "User object credentials that needs to sign in", "required": true, "schema": { "$ref": "#/definitions/Login" } } ], "responses": { "401": { "description": "A User Profile Cannot be Found!" }, "422": { "description": "Validation error | Bad request" }, "200": { "description": "Successfully login a user" } } } }, "/accounts": { "get": { "tags": [ "Accounts" ], "summary": "Get all bank accounts - filter by status [active, dormant]", "description": "N.B Only staff can perform this operation", "operationId": "getAccount", "produces": [ "application/xml", "application/json" ], "parameters": [ { "name": "status", "in": "query", "description": "Status values that need to be considered for filter", "required": false, "type": "array", "items": { "type": "string", "enum": [ "dormant", "active" ], "default": "all" }, "collectionFormat": "multi" } ], "responses": { "403": { "description": "Only Staff;s can perform this operation" }, "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "204": { "description": "No account waas found" }, "200": { "description": "Successfully fetched all bank accounts" } }, "security": [ { "bearerAuth": [] } ] }, "post": { "tags": [ "Accounts" ], "summary": "Create a bank account", "description": "", "operationId": "createAccount", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "body", "name": "body", "description": "User object credentials that needs to sign in", "required": true, "schema": { "$ref": "#/definitions/CreateAccount" } } ], "responses": { "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "A User Already have an Account or Account does exist or validation error" }, "200": { "description": "Successfully Created an Account" } }, "security": [ { "bearerAuth": [] } ] } }, "/accounts/{accountNumber}": { "parameters": [ { "name": "accountNumber", "in": "path", "description": "Account number of the account we want to work with", "required": true, "type": "integer" } ], "patch": { "tags": [ "Accounts" ], "summary": "Activate or deactivate an account.", "description": "N.B - Only Staff's can perform this operation", "operationId": "patchAccountByAccounNumber", "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "body", "name": "body", "description": "Specify a bank account status (active, dormant)", "schema": { "type": "object", "required": [ "status" ], "properties": { "status": { "type": "string", "example": "dormant" } } } } ], "responses": { "403": { "description": "User is not permitted to perform this operation" }, "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "Account number doesn't exist | Validation error" }, "200": { "description": "Status was successfully updated" } }, "security": [ { "bearerAuth": [] } ] }, "get": { "tags": [ "Accounts" ], "summary": "Get a specific account", "description": "N.B - a client can get only his/her account while a staff can get all accounts", "operationId": "getAccountByAccountNumber", "produces": [ "application/xml", "application/json" ], "responses": { "403": { "description": "User is not permitted to perform this operation" }, "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "Account number doesn't exist" }, "200": { "description": "Status was successfully updated" } }, "security": [ { "bearerAuth": [] } ] }, "delete": { "tags": [ "Accounts" ], "summary": "Deletes an account", "description": "N.B - Only Staff's can perform this operation", "operationId": "deleteAccount", "produces": [ "application/xml", "application/json" ], "responses": { "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "Account number doesn't exist" }, "200": { "description": "Status was successfully deleted" }, "403": { "description": "User is not permitted to perform this operation" } }, "security": [ { "bearerAuth": [] } ] } }, "/user/{email}/accounts": { "get": { "tags": [ "Accounts" ], "summary": "View all accounts owned by a specific user (client)​", "description": "N.B - user can only get personal accounts", "operationId": "userAccounts", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "email", "in": "path", "description": "An email address of a user", "required": true, "type": "string", "format": "email" } ], "responses": { "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "403": { "description": "User is not permitted to perform this operation" }, "400": { "description": "Account number doesn't exist" }, "200": { "description": "Accounts successfully fetched" } }, "security": [ { "bearerAuth": [] } ] } }, "/transactions/{accountNumber}/debit":{ "post": { "tags": [ "Transactions" ], "summary": "Debit a bank account.", "description": "", "operationId": "debitAccount", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "path", "name": "accountNumber", "description": "account number of user to perform transaction on", "required": true, "type": "integer", "format": "int64" }, { "in": "body", "name": "body", "description": "Amount to be debitted from the account", "schema": { "type": "object", "required": [ "amount" ], "properties": { "amount": { "type": "string", "example": "100" } } } } ], "responses": { "403": { "description": "User is not permitted to perform this operation" }, "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "Account number doesn't exist | Validation Error" }, "200": { "description": "Transaction was succesful" } }, "security": [ { "bearerAuth": [] } ] } }, "/transactions/{accountNumber}/credit":{ "post": { "tags": [ "Transactions" ], "summary": "Credit a bank account.", "description": "", "operationId": "creditAccount", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [ { "in": "path", "name": "accountNumber", "description": "account number of user to perform transaction on", "required": true, "type": "integer", "format": "int64" }, { "in": "body", "name": "amount", "description": "Amount to be debitted from the account", "schema": { "type": "object", "required": [ "amount" ], "properties": { "amount": { "type": "string", "example": "100" } } } } ], "responses": { "403": { "description": "User is not permitted to perform this operation" }, "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "Account number doesn't exist | Validation Error" }, "200": { "description": "Transaction was succesful" } }, "security": [ { "bearerAuth": [] } ] } }, "/accounts/{accountNumber}/transactions": { "get": { "tags": [ "Transactions" ], "summary": "View all transactions owned by a specific user", "description": "N.B - user can only get personal transactions while staff can get all transactions", "operationId": "userTransactions", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "accountNumber", "in": "path", "description": "Account number of the account we want to work with", "required": true, "type": "integer", "format": "int64" } ], "responses": { "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "403": { "description": "User is not permitted to perform this operation" }, "400": { "description": "Account number doesn't exist" }, "200": { "description": "Transactions successfully fetched" } }, "security": [ { "bearerAuth": [] } ] } }, "/transactions/{transactionId}":{ "get": { "tags": [ "Transactions" ], "summary": "Get a specific transaction", "description": "N.B - a client can get only his/her transactions while a staff can get all transactions", "operationId": "getTransactioById", "produces": [ "application/xml", "application/json" ], "parameters": [ { "name": "transactionId", "in": "path", "description": "Id of transaction you want to get", "required": true, "type": "integer", "format": "int64" } ], "responses": { "403": { "description": "User is not permitted to perform this operation" }, "401": { "description": "Uauthorized - Specify a JWToken in the header" }, "400": { "description": "Account number doesn't exist" }, "200": { "description": "Transactions successfully fetched" } }, "security": [ { "bearerAuth": [] } ] } } }, "securityDefinitions": { "bearerAuth": { "type": "apiKey", "scheme": "bearer", "description": "JWT token is received after registering/login, input format: \"Bearer \\<token\\>\"", "name": "x-access-token", "in": "header", "bearerFormat": "JWT" } }, "definitions": { "CreateAccount":{ "type": "object", "properties": { "type": { "type": "string", "example": "savings" }, "balance": { "type": "number", "example": "10000" } }, "xml": { "name": "CreateAccount" } }, "Login": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string", "format": "email", "example": "tejumolatimi@gmail.com" }, "password": { "type": "string", "example": "password" } }, "xml": { "name": "Login" } }, "User": { "type": "object", "required": [ "firstName", "lastName", "email", "password", "confirmPassword" ], "properties": { "firstName": { "type": "string", "example": "Timi" }, "lastName": { "type": "string", "example": "Tejumola" }, "email": { "type": "string", "format": "email", "example": "tejumolatimi@gmail.com" }, "password": { "type": "string", "example": "password" }, "confirmPassword": { "type": "string", "example": "password" } }, "xml": { "name": "User" } }, "Staff": { "type": "object", "required": [ "firstName", "lastName", "email", "password", "isAdmin" ], "properties": { "firstName": { "type": "string", "example": "Timi" }, "lastName": { "type": "string", "example": "Tejumola" }, "email": { "type": "string", "format": "email", "example": "tejumolatimi@gmail.com" }, "password": { "type": "string", "example": "password" }, "isAdmin": { "type": "boolean", "example": true } }, "xml": { "name": "Staff" } } }, "externalDocs": { "description": "Find out more about Swagger", "url": "http://swagger.io" }}