{ "consumes": [ "application/json" ], "produces": [ "application/json" ], "schemes": [ "http" ], "swagger": "2.0", "info": { "description": "Quizz-app", "version": "0.0.1-alpha" }, "host": "127.0.0.1", "basePath": "/api", "paths": { "/healthz": { "get": { "description": "Overall health check", "produces": [ "application/json" ], "tags": [ "Healthcheck" ], "summary": "Overall health check", "operationId": "overallHealthCheck", "responses": { "200": { "$ref": "#/responses/GenericResOk" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/healthz/db": { "get": { "description": "Database health check", "produces": [ "application/json" ], "tags": [ "Healthcheck" ], "summary": "Database health check", "operationId": "dbHealthCheck", "responses": { "200": { "$ref": "#/responses/GenericResOk" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/metrics": { "get": { "description": "Prometheus metrics endpoint", "produces": [ "text/plain" ], "tags": [ "Metrics" ], "summary": "Prometheus metrics endpoint", "operationId": "ReqMetrics" } }, "/v1/admin/quizzes/list": { "get": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "AdminUploadedQuizzes" ], "summary": "Get details of quizzes uploaded by Admin.", "operationId": "none", "responses": { "200": { "$ref": "#/responses/ResponseAdminUploadedQuizDetails" }, "400": { "$ref": "#/responses/GenericResFailNotFound" }, "401": { "$ref": "#/responses/GenericResFailConflict" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/v1/final_score/admin": { "get": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "FinalScoreForAdmin" ], "summary": "Get a finalScore details for admin.", "operationId": "RequestFinalScoreForAdmin", "parameters": [ { "type": "string", "x-go-name": "ActiveQuizId", "name": "active_quiz_id", "in": "query" } ], "responses": { "200": { "$ref": "#/responses/ResponseFinalScoreForAdmin" }, "400": { "$ref": "#/responses/GenericResFailNotFound" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/v1/final_score/user": { "get": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "FinalScoreForUser" ], "summary": "Get a finalScore details.", "operationId": "RequestFinalScore", "responses": { "200": { "$ref": "#/responses/ResponseFinalScore" }, "400": { "$ref": "#/responses/GenericResFailNotFound" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/v1/kratos/auth": { "get": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "Auth" ], "summary": "Authenticate user with kratos session id.", "operationId": "none", "responses": { "400": { "$ref": "#/responses/GenericResFailBadRequest" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/v1/login": { "post": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "Auth" ], "summary": "Authenticate user with email and password.", "operationId": "RequestAuthnUser", "parameters": [ { "name": "Body", "in": "body", "required": true, "schema": { "type": "object", "properties": { "email": { "type": "string", "x-go-name": "Email" }, "password": { "type": "string", "x-go-name": "Password" } } } } ], "responses": { "200": { "$ref": "#/responses/ResponseAuthnUser" }, "400": { "$ref": "#/responses/GenericResFailBadRequest" }, "401": { "$ref": "#/responses/ResForbiddenRequest" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/v1/users": { "post": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "Users" ], "summary": "Register a user.", "operationId": "RequestCreateUser", "parameters": [ { "name": "Body", "in": "body", "required": true, "schema": { "type": "object", "properties": { "email": { "type": "string", "x-go-name": "Email" }, "first_name": { "type": "string", "x-go-name": "FirstName" }, "last_name": { "type": "string", "x-go-name": "LastName" }, "password": { "type": "string", "x-go-name": "Password" }, "username": { "type": "string", "x-go-name": "UserName" } } } } ], "responses": { "201": { "$ref": "#/responses/ResponseCreateUser" }, "400": { "$ref": "#/responses/GenericResFailBadRequest" }, "500": { "$ref": "#/responses/GenericResError" } } } }, "/v1/users/{userId}": { "get": { "consumes": [ "application/json" ], "schemes": [ "http", "https" ], "tags": [ "Users" ], "summary": "Get a user.", "operationId": "RequestGetUser", "parameters": [ { "type": "string", "x-go-name": "UserId", "name": "userId", "in": "path", "required": true } ], "responses": { "200": { "$ref": "#/responses/ResponseGetUser" }, "400": { "$ref": "#/responses/GenericResFailNotFound" }, "500": { "$ref": "#/responses/GenericResError" } } } } }, "definitions": { "FinalScoreBoard": { "type": "object", "properties": { "response_time": { "type": "integer", "format": "int64", "x-go-name": "ResponseTime" }, "score": { "type": "integer", "format": "int64", "x-go-name": "Score" }, "username": { "type": "string", "x-go-name": "UserName" } }, "x-go-package": "github.com/Improwised/quizz-app/api/models" }, "NullString": { "description": "var s NullString\nerr := db.QueryRow(\"SELECT name FROM foo WHERE id=?\", id).Scan(\u0026s)\n...\nif s.Valid {\nuse s.String\n} else {\nNULL value\n}", "type": "object", "title": "NullString represents a string that may be null.\nNullString implements the Scanner interface so\nit can be used as a scan destination:", "properties": { "String": { "type": "string" }, "Valid": { "type": "boolean" } }, "x-go-package": "database/sql" }, "UUID": { "description": "A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC\n4122.", "type": "array", "items": { "type": "integer", "format": "uint8" }, "x-go-package": "github.com/google/uuid" } }, "responses": { "GenericResError": { "description": "Unexpected error occurred", "schema": { "type": "object", "properties": { "data": { "type": "object", "x-go-name": "Data" }, "message": { "type": "string", "x-go-name": "Message" }, "status": { "type": "string", "enum": [ "error" ], "x-go-name": "Status" } } } }, "GenericResFailBadRequest": { "description": "Fail due to user invalid input", "schema": { "type": "object", "properties": { "data": { "type": "object", "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "fail" ], "x-go-name": "Status" } } } }, "GenericResFailConflict": { "description": "Server understand request but refuse to authorize it", "schema": { "type": "object", "properties": { "data": { "type": "object", "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "fail" ], "x-go-name": "Status" } } } }, "GenericResFailNotFound": { "description": "Fail due to resource not exists", "schema": { "type": "object", "properties": { "data": { "type": "object", "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "fail" ], "x-go-name": "Status" } } } }, "GenericResFailUnprocessableEntity": { "description": "Fail due to server understand request but unable to process", "schema": { "type": "object", "properties": { "data": { "type": "object", "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "fail" ], "x-go-name": "Status" } } } }, "GenericResOk": { "description": "Response is okay", "schema": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "success" ], "x-go-name": "Status" } } } }, "ResForbiddenRequest": { "description": "Fail due to user invalid input", "schema": { "type": "object", "properties": { "data": { "type": "object", "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "fail" ], "x-go-name": "Status" } } } }, "ResponseAdminUploadedQuizDetails": { "description": "", "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "created_at": { "type": "string", "format": "date-time", "x-go-name": "CreatedAt" }, "creator_id": { "type": "string", "x-go-name": "CreatorID" }, "description": { "$ref": "#/definitions/NullString" }, "id": { "$ref": "#/definitions/UUID" }, "title": { "type": "string", "x-go-name": "Title" }, "total_questions": { "type": "integer", "format": "int64", "x-go-name": "TotalQuestions" }, "updated_at": { "type": "string", "format": "date-time", "x-go-name": "UpdatedAt" } }, "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "success" ], "x-go-name": "Status" } } } }, "ResponseAuthnUser": { "description": "", "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "created_at": { "type": "string", "x-go-name": "CreatedAt" }, "email": { "type": "string", "x-go-name": "Email" }, "first_name": { "type": "string", "x-go-name": "FirstName" }, "id": { "type": "string", "x-go-name": "ID" }, "kratos_id": { "type": "string", "x-go-name": "KratosID" }, "last_name": { "type": "string", "x-go-name": "LastName" }, "roles": { "type": "string", "x-go-name": "Roles" }, "updated_at": { "type": "string", "x-go-name": "UpdatedAt" }, "username": { "type": "string", "x-go-name": "Username" } }, "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "success" ], "x-go-name": "Status" } } } }, "ResponseCreateUser": { "description": "", "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "created_at": { "type": "string", "x-go-name": "CreatedAt" }, "email": { "type": "string", "x-go-name": "Email" }, "first_name": { "type": "string", "x-go-name": "FirstName" }, "id": { "type": "string", "x-go-name": "ID" }, "kratos_id": { "type": "string", "x-go-name": "KratosID" }, "last_name": { "type": "string", "x-go-name": "LastName" }, "roles": { "type": "string", "x-go-name": "Roles" }, "updated_at": { "type": "string", "x-go-name": "UpdatedAt" }, "username": { "type": "string", "x-go-name": "Username" } }, "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "success" ], "x-go-name": "Status" } } } }, "ResponseFinalScore": { "description": "", "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "FinalScore": { "type": "array", "items": { "$ref": "#/definitions/FinalScoreBoard" } } }, "x-go-name": "Data" }, "status": { "type": "string", "x-go-name": "Status" } } } }, "ResponseFinalScoreForAdmin": { "description": "", "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "FinalScore": { "type": "array", "items": { "$ref": "#/definitions/FinalScoreBoard" } } }, "x-go-name": "Data" }, "status": { "type": "string", "x-go-name": "Status" } } } }, "ResponseGetUser": { "description": "", "schema": { "type": "object", "properties": { "data": { "type": "object", "properties": { "created_at": { "type": "string", "x-go-name": "CreatedAt" }, "email": { "type": "string", "x-go-name": "Email" }, "first_name": { "type": "string", "x-go-name": "FirstName" }, "id": { "type": "string", "x-go-name": "ID" }, "kratos_id": { "type": "string", "x-go-name": "KratosID" }, "last_name": { "type": "string", "x-go-name": "LastName" }, "roles": { "type": "string", "x-go-name": "Roles" }, "updated_at": { "type": "string", "x-go-name": "UpdatedAt" }, "username": { "type": "string", "x-go-name": "Username" } }, "x-go-name": "Data" }, "status": { "type": "string", "enum": [ "success" ], "x-go-name": "Status" } } } } } }