{ "openapi": "3.0.1", "info": { "title": "Course Endpoint", "description": "This is a documentataion for courses", "version": "1.0.0" }, "servers": [ { "url": "http://localhost:1234/" } ], "tags": [ { "name": "exercises", "description": "This group represent exercise resource" }, { "name": "users", "description": "This group represent user resource" } ], "paths": { "/exercises": { "post": { "tags": [ "exercises" ], "summary": "create new exercise", "requestBody": { "description": "Created exercise object", "content": { "application/json": { "schema": { "type": "object", "required": [ "title", "description" ], "properties": { "title": { "type": "string" }, "description": { "type": "string" } } } } }, "required": true }, "responses": { "201": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "integer" }, "title": { "type": "string" }, "description": { "type": "string" } } } } } }, "400": { "description": "invalid input", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } }, "security": [ { "BearerAuth": [] } ] } }, "/exercises/{exerciseId}": { "get": { "tags": [ "exercises" ], "summary": "Get an exercise", "parameters": [ { "name": "exerciseId", "in": "path", "description": "ID of exercise to return", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "integer" }, "title": { "type": "string" }, "description": { "type": "string" }, "questions": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" }, "body": { "type": "string" }, "option_a": { "type": "string" }, "option_b": { "type": "string" }, "option_c": { "type": "string" }, "option_d": { "type": "string" }, "score": { "type": "string" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" } } } } } } } } }, "400": { "description": "invalid input", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } }, "404": { "description": "not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } }, "security": [ { "BearerAuth": [] } ] } }, "/exercises/{exerciseId}/score": { "get": { "tags": [ "exercises" ], "summary": "Get user score on that exercises", "description": "Return user score on that exercise", "parameters": [ { "name": "exerciseId", "in": "path", "description": "ID of exercise to return", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "score": { "type": "string", "description": "user score" } } } } } }, "404": { "description": "not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } }, "security": [ { "BearerAuth": [] } ] } }, "/exercises/{exerciseId}/questions": { "post": { "tags": [ "exercises" ], "summary": "Create questions of the exercise", "description": "Return user score on that exercise", "parameters": [ { "name": "exerciseId", "in": "path", "description": "ID of exercise to return", "required": true, "schema": { "type": "integer" } } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": [ "body", "option_a", "option_b", "option_c", "option_d", "correct_answer" ], "properties": { "body": { "type": "string" }, "option_a": { "type": "string" }, "option_b": { "type": "string" }, "option_c": { "type": "string" }, "option_d": { "type": "string" }, "correct_answer": { "type": "string" } } } } }, "required": true }, "responses": { "201": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "success message" } } } } } }, "400": { "description": "Invalid input", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } }, "404": { "description": "not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } }, "security": [ { "BearerAuth": [] } ] } }, "/exercises/{exerciseId}/questions/{questionId}/answer": { "post": { "tags": [ "exercises" ], "summary": "Answer the question of the exercises", "parameters": [ { "name": "exerciseId", "in": "path", "description": "ID of exercise to return", "required": true, "schema": { "type": "integer" } }, { "name": "questionId", "in": "path", "description": "ID of question to return", "required": true, "schema": { "type": "integer" } } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": [ "answer" ], "properties": { "answer": { "type": "string" } } } } }, "required": true }, "responses": { "201": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "success message" } } } } } }, "400": { "description": "Invalid input", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } }, "404": { "description": "not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } }, "security": [ { "BearerAuth": [] } ] } }, "/register": { "post": { "tags": [ "users" ], "summary": "Create user", "requestBody": { "description": "Created user object", "content": { "application/json": { "schema": { "type": "object", "required": [ "name", "email", "password" ], "properties": { "name": { "type": "string" }, "email": { "type": "string" }, "password": { "type": "string" }, "no_hp": { "type": "string" } } } } }, "required": true }, "responses": { "201": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string", "description": "user jwt token" } } } } } }, "400": { "description": "invalid input", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } } } }, "/login": { "post": { "tags": [ "users" ], "summary": "Login user to get jwt token", "requestBody": { "description": "Created user object", "content": { "application/json": { "schema": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string" }, "password": { "type": "string" } } } } }, "required": true }, "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string", "description": "user jwt token" } } } } } }, "400": { "description": "Invalid username/password", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "error message" } } } } } } } } } }, "components": { "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } }