{ "swagger": "2.0", "info": { "description": "A simple Go API that solves common Computer Science problems.", "title": "Algorithms API", "contact": {}, "version": "1.0" }, "paths": { "/knapsack": { "post": { "description": "Computes the solutions for the specified Knapsack problem instance, handling both the Binary and Fractional variants of the problem.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "Solves Knapsack problem", "parameters": [ { "description": "`values` represents the list of values of each object, `weights` represents the list of weights of each object, `capacity` represents the maximum weight the knapsack can hold.", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handlers.HandleKnapsack.requestBody" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/solvers.KnapsackResult" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/utils.ErrorResponse" } } } } }, "/n-queens": { "post": { "description": "Computes the solution for the specified N Queens problem instance, using the Forward Checking algorithm with MRV sorting.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "Solves N Queens problem", "parameters": [ { "description": "`n` represents the number of queens (one for each row/column), `blocked` represents the blocked squares on the chessboard.", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handlers.HandleNQueens.requestBody" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/solvers.NQueensResult" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/utils.ErrorResponse" } } } } }, "/shortest-path": { "post": { "description": "Computes the solution for the specified single-source Shortest Path problem instance, using Dijkstra's algorithm.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "Solves Shortest Path problem", "parameters": [ { "description": "`n` represents the number of nodes in the graph, `edges` represents the directed edges in the graph in a [start, end, weight] format, `source` represents the source node from which all paths will be calculated.", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handlers.HandleShortestPath.requestBody" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/solvers.ShortestPathResult" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/utils.ErrorResponse" } } } } }, "/status": { "get": { "description": "Used for testing purposes, when the user wants to check whether the server is currently running.", "produces": [ "application/json" ], "summary": "Returns the health status of the server", "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handlers.HandleStatus.StatusResponse" } } } } } }, "definitions": { "handlers.HandleKnapsack.requestBody": { "type": "object", "properties": { "capacity": { "type": "integer" }, "values": { "type": "array", "items": { "type": "integer" } }, "weights": { "type": "array", "items": { "type": "integer" } } } }, "handlers.HandleNQueens.requestBody": { "type": "object", "properties": { "blocked": { "type": "array", "items": { "type": "array", "items": { "type": "integer" } } }, "n": { "type": "integer" } } }, "handlers.HandleShortestPath.requestBody": { "type": "object", "properties": { "edges": { "type": "array", "items": { "type": "array", "items": { "type": "integer" } } }, "n": { "type": "integer" }, "source": { "type": "integer" } } }, "handlers.HandleStatus.StatusResponse": { "type": "object", "properties": { "status": { "type": "string" } } }, "solvers.KnapsackResult": { "type": "object", "properties": { "binary_solution": { "$ref": "#/definitions/solvers.KnapsackResultData-int" }, "formatted_output": { "type": "string" }, "fractional_solution": { "$ref": "#/definitions/solvers.KnapsackResultData-float64" }, "message": { "type": "string" } } }, "solvers.KnapsackResultData-float64": { "type": "object", "properties": { "max_value": { "type": "number" }, "max_weight": { "type": "number" }, "selected_items": { "type": "array", "items": { "$ref": "#/definitions/solvers.KnapsackResultItem-float64" } } } }, "solvers.KnapsackResultData-int": { "type": "object", "properties": { "max_value": { "type": "integer" }, "max_weight": { "type": "integer" }, "selected_items": { "type": "array", "items": { "$ref": "#/definitions/solvers.KnapsackResultItem-int" } } } }, "solvers.KnapsackResultItem-float64": { "type": "object", "properties": { "number": { "type": "integer" }, "ratio": { "type": "number" }, "value": { "type": "number" }, "weight": { "type": "number" } } }, "solvers.KnapsackResultItem-int": { "type": "object", "properties": { "number": { "type": "integer" }, "ratio": { "type": "number" }, "value": { "type": "integer" }, "weight": { "type": "integer" } } }, "solvers.NQueensResult": { "type": "object", "properties": { "formatted_output": { "type": "string" }, "iterations": { "type": "integer" }, "message": { "type": "string" }, "solution": { "type": "array", "items": { "$ref": "#/definitions/solvers.NQueensResultQueen" } } } }, "solvers.NQueensResultQueen": { "type": "object", "properties": { "col": { "type": "integer" }, "domain": { "type": "array", "items": { "type": "integer" } }, "row": { "type": "integer" } } }, "solvers.ShortestPathResult": { "type": "object", "properties": { "formatted_output": { "type": "string" }, "message": { "type": "string" }, "solution": { "type": "array", "items": { "$ref": "#/definitions/solvers.ShortestPathResultNode" } } } }, "solvers.ShortestPathResultNode": { "type": "object", "properties": { "distance": { "type": "integer" }, "node": { "type": "integer" }, "path": { "type": "array", "items": { "type": "integer" } } } }, "utils.ErrorResponse": { "type": "object", "properties": { "error": { "type": "string" } } } } }