{ "swagger": "2.0", "info": { "version": "1.0.0", "title": "AIKAVALI-BACK", "description": "Backend for the ohtu aikavali project" }, "host": "localhost:8080", "basePath": "/api/v1", "tags": [ { "name": "Example", "description": "Example API endpoints" }, { "name": "Questions", "description": "Question API" }, { "name": "User", "description": "User API" }, { "name": "Answer", "description": "Answer API" } ], "schemes": [ "http" ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "securityDefinitions": { "Bearer": { "type": "apiKey", "name": "Authorization", "in": "header" } }, "paths": { "/example": { "get": { "tags": [ "Example" ], "summary": "Example get", "responses": { "200": { "description": "OK" } } } }, "/questions": { "get": { "tags": [ "Questions" ], "summary": "Returns all different questions", "responses": { "200": { "description": "OK" }, "500": { "description": "ERROR" } } } }, "/questions/{id}": { "delete": { "tags": [ "Questions" ], "summary": "Deletes a question and all other info that relates to it", "parameters": [ { "in": "path", "name": "id", "description": "question's id", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK" }, "500": { "description": "ERROR" } } } }, "/questions/random": { "get": { "tags": [ "Questions" ], "summary": "Returns a random question", "parameters": [ { "in": "body", "name": "token", "description": "user token", "schema": { "type": "object" } } ], "responses": { "200": { "description": "OK" }, "500": { "description": "ERROR" } } } }, "/questions/print": { "post": { "tags": [ "Questions" ], "summary": "Creates a new question of type print", "parameters": [ { "in": "body", "name": "value", "description": "value/name of the new question", "schema": { "type": "string" } }, { "in": "body", "name": "correctAnswer", "description": "correct answer to the question", "schema": { "type": "string" } }, { "in": "body", "name": "options", "description": "other options that the question has", "schema": { "type": "array", "items": { "type": "string" } } } ], "responses": { "201": { "description": "CREATED QUESTION" }, "500": { "description": "ERROR" } } } }, "/questions/compile": { "post": { "tags": [ "Questions" ], "summary": "Creates a new question of type compile", "parameters": [ { "in": "body", "name": "correctAnswer", "description": "correct answer to the question", "schema": { "type": "string" } }, { "in": "body", "name": "options", "description": "other options that the question has", "schema": { "type": "array", "items": { "type": "string" } } } ], "responses": { "201": { "description": "CREATED QUESTION" }, "500": { "description": "ERROR" } } } }, "/user/login": { "post": { "tags": [ "User" ], "summary": "Returns a jsonwebtoken", "parameters": [ { "in": "body", "name": "user", "description": "an object with accessToken parameter", "schema": { "type": "object" } } ], "responses": { "200": { "description": "OK" }, "500": { "description": "ERROR" } } } }, "/user/generate": { "post": { "tags": [ "User" ], "summary": "Creates a new user and returns a jsonwebtoken", "responses": { "201": { "description": "CREATED" }, "500": { "description": "ERROR" } } } }, "/user/verifyToken": { "get": { "tags": [ "User" ], "summary": "Checks whether a token is valid", "security": [ {"Bearer": []} ], "responses": { "200": { "description": "OK" } } } }, "/questions/answer": { "post": { "tags": [ "Questions" ], "summary": "Returns true if the given answer was correct", "parameters": [ { "in": "body", "name": "id", "description": "id of the question that was answered", "schema": { "type": "string" } }, { "in": "body", "name": "answer", "description": "user's answer", "schema": { "type": "string" } } ], "responses": { "200": { "description": "{ isCorrect: true/false }" }, "500": { "description": "ERROR" } } } }, "/answer/{userId}": { "get": { "tags": [ "Answer" ], "summary": "Returns all answers that are linked to a specific user", "parameters": [ { "in": "path", "name": "userId", "description": "user's id", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK" }, "500": { "description": "ERROR" } } } } } }