diff --git a/amqp/amqp_endpoints.go b/amqp/amqp_endpoints.go index ff4e3bf..973c544 100644 --- a/amqp/amqp_endpoints.go +++ b/amqp/amqp_endpoints.go @@ -47,6 +47,7 @@ func RegisterAMQPEndpoint(r *gin.RouterGroup) { // @Failure 500 {object} docs.ResponseError "Internal server error" // @Param ICID path int true "InfrastructureComponent ID" // @Router /ic/{ICID}/action [post] +// @Security Bearer func sendActionToIC(c *gin.Context) { ok, s := infrastructure_component.CheckPermissions(c, database.ModelInfrastructureComponentAction, database.Update, true) diff --git a/doc/api/docs.go b/doc/api/docs.go index b9b3711..a32cd60 100644 --- a/doc/api/docs.go +++ b/doc/api/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-07-06 15:29:44.957174619 +0200 CEST m=+0.089303074 +// 2020-09-25 16:13:15.130920598 +0200 CEST m=+0.092357808 package docs @@ -81,6 +81,11 @@ var doc = `{ }, "/configs": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -90,13 +95,6 @@ var doc = `{ "summary": "Get all component configurations of scenario", "operationId": "getConfigs", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -133,6 +131,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -145,13 +148,6 @@ var doc = `{ "summary": "Add a component configuration to a scenario", "operationId": "addConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "component configuration to be added incl. IDs of scenario and IC", "name": "inputConfig", @@ -199,6 +195,11 @@ var doc = `{ }, "/configs/{configID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -208,13 +209,6 @@ var doc = `{ "summary": "Get a component configuration", "operationId": "getConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Config ID", @@ -257,6 +251,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -269,13 +268,6 @@ var doc = `{ "summary": "Update a component configuration", "operationId": "updateConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "component configuration to be updated", "name": "inputConfig", @@ -328,6 +320,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -337,13 +334,6 @@ var doc = `{ "summary": "Delete a component configuration", "operationId": "deleteConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Config ID", @@ -388,6 +378,11 @@ var doc = `{ }, "/dashboards": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -397,13 +392,6 @@ var doc = `{ "summary": "Get all dashboards of scenario", "operationId": "getDashboards", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -440,6 +428,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -452,13 +445,6 @@ var doc = `{ "summary": "Add a dashboard to a scenario", "operationId": "addDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Dashboard to be added incl. ID of Scenario", "name": "inputDab", @@ -506,6 +492,11 @@ var doc = `{ }, "/dashboards/{dashboardID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -515,13 +506,6 @@ var doc = `{ "summary": "Get a dashboard", "operationId": "getDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Dashboard ID", @@ -564,6 +548,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -576,13 +565,6 @@ var doc = `{ "summary": "Update a dashboard", "operationId": "updateDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Dashboard to be updated", "name": "inputDab", @@ -635,6 +617,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -644,13 +631,6 @@ var doc = `{ "summary": "Delete a dashboard", "operationId": "deleteDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Dashboard ID", @@ -695,6 +675,11 @@ var doc = `{ }, "/files": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -704,13 +689,6 @@ var doc = `{ "summary": "Get all files of a specific scenario", "operationId": "getFiles", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -747,13 +725,19 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "text/plain", "image/png", "image/jpeg", "image/gif", "model/x-cim", - "model/x-cim.zip" + "model/x-cim.zip", + "multipart/form-data" ], "produces": [ "application/json" @@ -764,13 +748,6 @@ var doc = `{ "summary": "Add a file to a specific scenario", "operationId": "addFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "file", "description": "File to be uploaded", @@ -822,6 +799,11 @@ var doc = `{ }, "/files/{fileID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "text/plain", "image/png", @@ -836,13 +818,6 @@ var doc = `{ "summary": "Download a file", "operationId": "getFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of the file to download", @@ -885,13 +860,19 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "text/plain", "image/png", "image/jpeg", "image/gif", "model/x-cim", - "model/x-cim.zip" + "model/x-cim.zip", + "multipart/form-data" ], "produces": [ "application/json" @@ -902,13 +883,6 @@ var doc = `{ "summary": "Update a file", "operationId": "updateFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "file", "description": "File to be uploaded", @@ -958,6 +932,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -967,13 +946,6 @@ var doc = `{ "summary": "Delete a file", "operationId": "deleteFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of the file to update", @@ -1041,6 +1013,11 @@ var doc = `{ }, "/ic": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1049,15 +1026,6 @@ var doc = `{ ], "summary": "Get all infrastructure components", "operationId": "getICs", - "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - } - ], "responses": { "200": { "description": "ICs requested", @@ -1086,6 +1054,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1098,13 +1071,6 @@ var doc = `{ "summary": "Add an infrastructure component", "operationId": "addIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Infrastructure Component to be added", "name": "inputIC", @@ -1152,6 +1118,11 @@ var doc = `{ }, "/ic/{ICID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1161,13 +1132,6 @@ var doc = `{ "summary": "Get infrastructure component", "operationId": "getIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Infrastructure Component ID", @@ -1210,6 +1174,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1222,13 +1191,6 @@ var doc = `{ "summary": "Update an infrastructure component", "operationId": "updateIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "InfrastructureComponent to be updated", "name": "inputIC", @@ -1281,6 +1243,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1290,13 +1257,6 @@ var doc = `{ "summary": "Delete an infrastructure component", "operationId": "deleteIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Infrastructure Component ID", @@ -1341,6 +1301,11 @@ var doc = `{ }, "/ic/{ICID}/action": { "post": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1401,6 +1366,11 @@ var doc = `{ }, "/ic/{ICID}/configs": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1410,13 +1380,6 @@ var doc = `{ "summary": "Get all configurations of the infrastructure component", "operationId": "getConfigsOfIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Infrastructure Component ID", @@ -1478,6 +1441,11 @@ var doc = `{ }, "/scenarios": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1486,15 +1454,6 @@ var doc = `{ ], "summary": "Get all scenarios of requesting user", "operationId": "getScenarios", - "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - } - ], "responses": { "200": { "description": "Scenarios to which user has access", @@ -1523,6 +1482,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1535,13 +1499,6 @@ var doc = `{ "summary": "Add a scenario", "operationId": "addScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Scenario to be added", "name": "inputScenario", @@ -1589,6 +1546,11 @@ var doc = `{ }, "/scenarios/{scenarioID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1598,13 +1560,6 @@ var doc = `{ "summary": "Get scenario", "operationId": "getScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1641,6 +1596,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1653,13 +1613,6 @@ var doc = `{ "summary": "Update a scenario", "operationId": "updateScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Scenario to be updated", "name": "inputScenario", @@ -1712,6 +1665,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1721,13 +1679,6 @@ var doc = `{ "summary": "Delete a scenario", "operationId": "deleteScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1766,6 +1717,11 @@ var doc = `{ }, "/scenarios/{scenarioID}/user": { "put": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1775,13 +1731,6 @@ var doc = `{ "summary": "Add a user to a a scenario", "operationId": "addUserToScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1825,6 +1774,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1834,13 +1788,6 @@ var doc = `{ "summary": "Delete a user from a scenario", "operationId": "deleteUserFromScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1886,6 +1833,11 @@ var doc = `{ }, "/scenarios/{scenarioID}/users/": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1895,13 +1847,6 @@ var doc = `{ "summary": "Get users of a scenario", "operationId": "getUsersOfScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1940,6 +1885,11 @@ var doc = `{ }, "/signals": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1962,13 +1912,6 @@ var doc = `{ "name": "configID", "in": "query", "required": true - }, - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true } ], "responses": { @@ -1999,6 +1942,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2011,13 +1959,6 @@ var doc = `{ "summary": "Add a signal to a signal mapping of a component configuration", "operationId": "AddSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "A signal to be added to the component configuration incl. direction and config ID to which signal shall be added", "name": "inputSignal", @@ -2065,6 +2006,11 @@ var doc = `{ }, "/signals/{signalID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2074,13 +2020,6 @@ var doc = `{ "summary": "Get a signal", "operationId": "getSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of signal to be obtained", @@ -2123,6 +2062,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2132,13 +2076,6 @@ var doc = `{ "summary": "Update a signal", "operationId": "updateSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "A signal to be updated", "name": "inputSignal", @@ -2191,6 +2128,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2200,13 +2142,6 @@ var doc = `{ "summary": "Delete a signal", "operationId": "deleteSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of signal to be deleted", @@ -2251,6 +2186,11 @@ var doc = `{ }, "/users": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2259,15 +2199,6 @@ var doc = `{ ], "summary": "Get all users", "operationId": "GetUsers", - "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - } - ], "responses": { "200": { "description": "Array of users", @@ -2296,6 +2227,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2317,13 +2253,6 @@ var doc = `{ "type": "object", "$ref": "#/definitions/user.addUserRequest" } - }, - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true } ], "responses": { @@ -2356,6 +2285,11 @@ var doc = `{ }, "/users/{userID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2365,13 +2299,6 @@ var doc = `{ "summary": "Get user", "operationId": "GetUser", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "User ID", @@ -2414,6 +2341,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2426,13 +2358,6 @@ var doc = `{ "summary": "Update a user", "operationId": "UpdateUser", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "User to be updated (anything except for ID can be changed, role can only be change by admin)", "name": "inputUser", @@ -2491,6 +2416,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2500,13 +2430,6 @@ var doc = `{ "summary": "Delete a user", "operationId": "DeleteUser", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "User ID", @@ -2545,6 +2468,11 @@ var doc = `{ }, "/widgets": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2554,13 +2482,6 @@ var doc = `{ "summary": "Get all widgets of dashboard", "operationId": "getWidgets", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Dashboard ID", @@ -2597,6 +2518,11 @@ var doc = `{ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2609,13 +2535,6 @@ var doc = `{ "summary": "Add a widget to a dashboard", "operationId": "addWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Widget to be added incl. ID of dashboard", "name": "inputWidget", @@ -2663,6 +2582,11 @@ var doc = `{ }, "/widgets/{widgetID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2672,13 +2596,6 @@ var doc = `{ "summary": "Get a widget", "operationId": "getWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Widget ID", @@ -2721,6 +2638,11 @@ var doc = `{ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2733,13 +2655,6 @@ var doc = `{ "summary": "Update a widget", "operationId": "updateWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Widget to be updated", "name": "inputWidget", @@ -2792,6 +2707,11 @@ var doc = `{ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2801,13 +2721,6 @@ var doc = `{ "summary": "Delete a widget", "operationId": "deleteWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Widget ID", @@ -3460,7 +3373,6 @@ var doc = `{ "type": "object", "required": [ "Category", - "Host", "Name", "Type", "UUID" @@ -3830,6 +3742,13 @@ var doc = `{ } } } + }, + "securityDefinitions": { + "Bearer": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } } }` @@ -3846,10 +3765,10 @@ type swaggerInfo struct { var SwaggerInfo = swaggerInfo{ Version: "2.0", Host: "", - BasePath: "/api/v2", + BasePath: "http://localhost:4000/api/v2/", Schemes: []string{}, Title: "VILLASweb Backend API", - Description: "This is the VILLASweb Backend API v2.0.\nParts of this API are still in development. Please check the [VILLASweb-backend-go repository](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) for more information.\nThis documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework.", + Description: "This is the [VILLASweb Backend](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) API v2.0.\nThis documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework.\nAuthentication: Use the authenticate endpoint below to obtain a token for your user account, copy the token into to the value field of the dialog showing up for the green Authorize button below and confirm with Done.", } type s struct{} diff --git a/doc/api/swagger.json b/doc/api/swagger.json index 1575bce..20834e5 100644 --- a/doc/api/swagger.json +++ b/doc/api/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "description": "This is the VILLASweb Backend API v2.0.\nParts of this API are still in development. Please check the [VILLASweb-backend-go repository](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) for more information.\nThis documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework.", + "description": "This is the [VILLASweb Backend](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) API v2.0.\nThis documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework.\nAuthentication: Use the authenticate endpoint below to obtain a token for your user account, copy the token into to the value field of the dialog showing up for the green Authorize button below and confirm with Done.", "title": "VILLASweb Backend API", "contact": { "name": "Sonja Happ", @@ -13,7 +13,7 @@ }, "version": "2.0" }, - "basePath": "/api/v2", + "basePath": "http://localhost:4000/api/v2/", "paths": { "/authenticate": { "post": { @@ -64,6 +64,11 @@ }, "/configs": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -73,13 +78,6 @@ "summary": "Get all component configurations of scenario", "operationId": "getConfigs", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -116,6 +114,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -128,13 +131,6 @@ "summary": "Add a component configuration to a scenario", "operationId": "addConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "component configuration to be added incl. IDs of scenario and IC", "name": "inputConfig", @@ -182,6 +178,11 @@ }, "/configs/{configID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -191,13 +192,6 @@ "summary": "Get a component configuration", "operationId": "getConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Config ID", @@ -240,6 +234,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -252,13 +251,6 @@ "summary": "Update a component configuration", "operationId": "updateConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "component configuration to be updated", "name": "inputConfig", @@ -311,6 +303,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -320,13 +317,6 @@ "summary": "Delete a component configuration", "operationId": "deleteConfig", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Config ID", @@ -371,6 +361,11 @@ }, "/dashboards": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -380,13 +375,6 @@ "summary": "Get all dashboards of scenario", "operationId": "getDashboards", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -423,6 +411,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -435,13 +428,6 @@ "summary": "Add a dashboard to a scenario", "operationId": "addDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Dashboard to be added incl. ID of Scenario", "name": "inputDab", @@ -489,6 +475,11 @@ }, "/dashboards/{dashboardID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -498,13 +489,6 @@ "summary": "Get a dashboard", "operationId": "getDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Dashboard ID", @@ -547,6 +531,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -559,13 +548,6 @@ "summary": "Update a dashboard", "operationId": "updateDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Dashboard to be updated", "name": "inputDab", @@ -618,6 +600,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -627,13 +614,6 @@ "summary": "Delete a dashboard", "operationId": "deleteDashboard", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Dashboard ID", @@ -678,6 +658,11 @@ }, "/files": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -687,13 +672,6 @@ "summary": "Get all files of a specific scenario", "operationId": "getFiles", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -730,13 +708,19 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "text/plain", "image/png", "image/jpeg", "image/gif", "model/x-cim", - "model/x-cim.zip" + "model/x-cim.zip", + "multipart/form-data" ], "produces": [ "application/json" @@ -747,13 +731,6 @@ "summary": "Add a file to a specific scenario", "operationId": "addFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "file", "description": "File to be uploaded", @@ -805,6 +782,11 @@ }, "/files/{fileID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "text/plain", "image/png", @@ -819,13 +801,6 @@ "summary": "Download a file", "operationId": "getFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of the file to download", @@ -868,13 +843,19 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "text/plain", "image/png", "image/jpeg", "image/gif", "model/x-cim", - "model/x-cim.zip" + "model/x-cim.zip", + "multipart/form-data" ], "produces": [ "application/json" @@ -885,13 +866,6 @@ "summary": "Update a file", "operationId": "updateFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "file", "description": "File to be uploaded", @@ -941,6 +915,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -950,13 +929,6 @@ "summary": "Delete a file", "operationId": "deleteFile", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of the file to update", @@ -1024,6 +996,11 @@ }, "/ic": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1032,15 +1009,6 @@ ], "summary": "Get all infrastructure components", "operationId": "getICs", - "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - } - ], "responses": { "200": { "description": "ICs requested", @@ -1069,6 +1037,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1081,13 +1054,6 @@ "summary": "Add an infrastructure component", "operationId": "addIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Infrastructure Component to be added", "name": "inputIC", @@ -1135,6 +1101,11 @@ }, "/ic/{ICID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1144,13 +1115,6 @@ "summary": "Get infrastructure component", "operationId": "getIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Infrastructure Component ID", @@ -1193,6 +1157,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1205,13 +1174,6 @@ "summary": "Update an infrastructure component", "operationId": "updateIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "InfrastructureComponent to be updated", "name": "inputIC", @@ -1264,6 +1226,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1273,13 +1240,6 @@ "summary": "Delete an infrastructure component", "operationId": "deleteIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Infrastructure Component ID", @@ -1324,6 +1284,11 @@ }, "/ic/{ICID}/action": { "post": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1384,6 +1349,11 @@ }, "/ic/{ICID}/configs": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1393,13 +1363,6 @@ "summary": "Get all configurations of the infrastructure component", "operationId": "getConfigsOfIC", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Infrastructure Component ID", @@ -1461,6 +1424,11 @@ }, "/scenarios": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1469,15 +1437,6 @@ ], "summary": "Get all scenarios of requesting user", "operationId": "getScenarios", - "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - } - ], "responses": { "200": { "description": "Scenarios to which user has access", @@ -1506,6 +1465,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1518,13 +1482,6 @@ "summary": "Add a scenario", "operationId": "addScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Scenario to be added", "name": "inputScenario", @@ -1572,6 +1529,11 @@ }, "/scenarios/{scenarioID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1581,13 +1543,6 @@ "summary": "Get scenario", "operationId": "getScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1624,6 +1579,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1636,13 +1596,6 @@ "summary": "Update a scenario", "operationId": "updateScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Scenario to be updated", "name": "inputScenario", @@ -1695,6 +1648,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1704,13 +1662,6 @@ "summary": "Delete a scenario", "operationId": "deleteScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1749,6 +1700,11 @@ }, "/scenarios/{scenarioID}/user": { "put": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1758,13 +1714,6 @@ "summary": "Add a user to a a scenario", "operationId": "addUserToScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1808,6 +1757,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1817,13 +1771,6 @@ "summary": "Delete a user from a scenario", "operationId": "deleteUserFromScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1869,6 +1816,11 @@ }, "/scenarios/{scenarioID}/users/": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1878,13 +1830,6 @@ "summary": "Get users of a scenario", "operationId": "getUsersOfScenario", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Scenario ID", @@ -1923,6 +1868,11 @@ }, "/signals": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -1945,13 +1895,6 @@ "name": "configID", "in": "query", "required": true - }, - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true } ], "responses": { @@ -1982,6 +1925,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -1994,13 +1942,6 @@ "summary": "Add a signal to a signal mapping of a component configuration", "operationId": "AddSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "A signal to be added to the component configuration incl. direction and config ID to which signal shall be added", "name": "inputSignal", @@ -2048,6 +1989,11 @@ }, "/signals/{signalID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2057,13 +2003,6 @@ "summary": "Get a signal", "operationId": "getSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of signal to be obtained", @@ -2106,6 +2045,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2115,13 +2059,6 @@ "summary": "Update a signal", "operationId": "updateSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "A signal to be updated", "name": "inputSignal", @@ -2174,6 +2111,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2183,13 +2125,6 @@ "summary": "Delete a signal", "operationId": "deleteSignal", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "ID of signal to be deleted", @@ -2234,6 +2169,11 @@ }, "/users": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2242,15 +2182,6 @@ ], "summary": "Get all users", "operationId": "GetUsers", - "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - } - ], "responses": { "200": { "description": "Array of users", @@ -2279,6 +2210,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2300,13 +2236,6 @@ "type": "object", "$ref": "#/definitions/user.addUserRequest" } - }, - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true } ], "responses": { @@ -2339,6 +2268,11 @@ }, "/users/{userID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2348,13 +2282,6 @@ "summary": "Get user", "operationId": "GetUser", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "User ID", @@ -2397,6 +2324,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2409,13 +2341,6 @@ "summary": "Update a user", "operationId": "UpdateUser", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "User to be updated (anything except for ID can be changed, role can only be change by admin)", "name": "inputUser", @@ -2474,6 +2399,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2483,13 +2413,6 @@ "summary": "Delete a user", "operationId": "DeleteUser", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "User ID", @@ -2528,6 +2451,11 @@ }, "/widgets": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2537,13 +2465,6 @@ "summary": "Get all widgets of dashboard", "operationId": "getWidgets", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Dashboard ID", @@ -2580,6 +2501,11 @@ } }, "post": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2592,13 +2518,6 @@ "summary": "Add a widget to a dashboard", "operationId": "addWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Widget to be added incl. ID of dashboard", "name": "inputWidget", @@ -2646,6 +2565,11 @@ }, "/widgets/{widgetID}": { "get": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2655,13 +2579,6 @@ "summary": "Get a widget", "operationId": "getWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Widget ID", @@ -2704,6 +2621,11 @@ } }, "put": { + "security": [ + { + "Bearer": [] + } + ], "consumes": [ "application/json" ], @@ -2716,13 +2638,6 @@ "summary": "Update a widget", "operationId": "updateWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "description": "Widget to be updated", "name": "inputWidget", @@ -2775,6 +2690,11 @@ } }, "delete": { + "security": [ + { + "Bearer": [] + } + ], "produces": [ "application/json" ], @@ -2784,13 +2704,6 @@ "summary": "Delete a widget", "operationId": "deleteWidget", "parameters": [ - { - "type": "string", - "description": "Authorization token", - "name": "Authorization", - "in": "header", - "required": true - }, { "type": "integer", "description": "Widget ID", @@ -3443,7 +3356,6 @@ "type": "object", "required": [ "Category", - "Host", "Name", "Type", "UUID" @@ -3813,5 +3725,12 @@ } } } + }, + "securityDefinitions": { + "Bearer": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } } } \ No newline at end of file diff --git a/doc/api/swagger.yaml b/doc/api/swagger.yaml index dd10877..8668a64 100644 --- a/doc/api/swagger.yaml +++ b/doc/api/swagger.yaml @@ -1,4 +1,4 @@ -basePath: /api/v2 +basePath: http://localhost:4000/api/v2/ definitions: component_configuration.addConfigRequest: properties: @@ -436,7 +436,6 @@ definitions: type: string required: - Category - - Host - Name - Type - UUID @@ -672,9 +671,9 @@ info: email: sonja.happ@eonerc.rwth-aachen.de name: Sonja Happ description: |- - This is the VILLASweb Backend API v2.0. - Parts of this API are still in development. Please check the [VILLASweb-backend-go repository](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) for more information. + This is the [VILLASweb Backend](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) API v2.0. This documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework. + Authentication: Use the authenticate endpoint below to obtain a token for your user account, copy the token into to the value field of the dialog showing up for the green Authorize button below and confirm with Done. license: name: GNU GPL 3.0 url: http://www.gnu.de/documents/gpl-3.0.en.html @@ -717,11 +716,6 @@ paths: get: operationId: getConfigs parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: query name: scenarioID @@ -746,6 +740,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all component configurations of scenario tags: - component-configurations @@ -754,11 +750,6 @@ paths: - application/json operationId: addConfig parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: component configuration to be added incl. IDs of scenario and IC in: body @@ -790,6 +781,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a component configuration to a scenario tags: - component-configurations @@ -797,11 +790,6 @@ paths: delete: operationId: deleteConfig parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Config ID in: path name: configID @@ -830,17 +818,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a component configuration tags: - component-configurations get: operationId: getConfig parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Config ID in: path name: configID @@ -869,6 +854,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get a component configuration tags: - component-configurations @@ -877,11 +864,6 @@ paths: - application/json operationId: updateConfig parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: component configuration to be updated in: body name: inputConfig @@ -917,6 +899,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a component configuration tags: - component-configurations @@ -924,11 +908,6 @@ paths: get: operationId: getDashboards parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: query name: scenarioID @@ -953,6 +932,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all dashboards of scenario tags: - dashboards @@ -961,11 +942,6 @@ paths: - application/json operationId: addDashboard parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Dashboard to be added incl. ID of Scenario in: body name: inputDab @@ -996,6 +972,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a dashboard to a scenario tags: - dashboards @@ -1003,11 +981,6 @@ paths: delete: operationId: deleteDashboard parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Dashboard ID in: path name: dashboardID @@ -1036,17 +1009,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a dashboard tags: - dashboards get: operationId: getDashboard parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Dashboard ID in: path name: dashboardID @@ -1075,6 +1045,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get a dashboard tags: - dashboards @@ -1083,11 +1055,6 @@ paths: - application/json operationId: updateDashboard parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Dashboard to be updated in: body name: inputDab @@ -1123,6 +1090,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a dashboard tags: - dashboards @@ -1130,11 +1099,6 @@ paths: get: operationId: getFiles parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: query name: scenarioID @@ -1159,6 +1123,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all files of a specific scenario tags: - files @@ -1170,13 +1136,9 @@ paths: - image/gif - model/x-cim - model/x-cim.zip + - multipart/form-data operationId: addFile parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: File to be uploaded in: formData name: inputFile @@ -1210,6 +1172,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a file to a specific scenario tags: - files @@ -1217,11 +1181,6 @@ paths: delete: operationId: deleteFile parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: ID of the file to update in: path name: fileID @@ -1250,17 +1209,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a file tags: - files get: operationId: getFile parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: ID of the file to download in: path name: fileID @@ -1294,6 +1250,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Download a file tags: - files @@ -1305,13 +1263,9 @@ paths: - image/gif - model/x-cim - model/x-cim.zip + - multipart/form-data operationId: updateFile parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: File to be uploaded in: formData name: inputFile @@ -1345,6 +1299,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a file tags: - files @@ -1367,12 +1323,6 @@ paths: /ic: get: operationId: getICs - parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string produces: - application/json responses: @@ -1392,6 +1342,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all infrastructure components tags: - infrastructure-components @@ -1400,11 +1352,6 @@ paths: - application/json operationId: addIC parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Infrastructure Component to be added in: body name: inputIC @@ -1435,6 +1382,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add an infrastructure component tags: - infrastructure-components @@ -1442,11 +1391,6 @@ paths: delete: operationId: deleteIC parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Infrastructure Component ID in: path name: ICID @@ -1475,17 +1419,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete an infrastructure component tags: - infrastructure-components get: operationId: getIC parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Infrastructure Component ID in: path name: ICID @@ -1514,6 +1455,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get infrastructure component tags: - infrastructure-components @@ -1522,11 +1465,6 @@ paths: - application/json operationId: updateIC parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: InfrastructureComponent to be updated in: body name: inputIC @@ -1562,6 +1500,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update an infrastructure component tags: - infrastructure-components @@ -1602,6 +1542,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Send an action to IC (only available if backend server is started with -amqp parameter) tags: @@ -1610,11 +1552,6 @@ paths: get: operationId: getConfigsOfIC parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Infrastructure Component ID in: path name: ICID @@ -1643,6 +1580,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all configurations of the infrastructure component tags: - infrastructure-components @@ -1660,12 +1599,6 @@ paths: /scenarios: get: operationId: getScenarios - parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string produces: - application/json responses: @@ -1685,6 +1618,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all scenarios of requesting user tags: - scenarios @@ -1693,11 +1628,6 @@ paths: - application/json operationId: addScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario to be added in: body name: inputScenario @@ -1728,6 +1658,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a scenario tags: - scenarios @@ -1735,11 +1667,6 @@ paths: delete: operationId: deleteScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: path name: scenarioID @@ -1764,17 +1691,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a scenario tags: - scenarios get: operationId: getScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: path name: scenarioID @@ -1799,6 +1723,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get scenario tags: - scenarios @@ -1807,11 +1733,6 @@ paths: - application/json operationId: updateScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario to be updated in: body name: inputScenario @@ -1847,6 +1768,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a scenario tags: - scenarios @@ -1854,11 +1777,6 @@ paths: delete: operationId: deleteUserFromScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: path name: scenarioID @@ -1888,17 +1806,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a user from a scenario tags: - scenarios put: operationId: addUserToScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: path name: scenarioID @@ -1928,6 +1843,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a user to a a scenario tags: - scenarios @@ -1935,11 +1852,6 @@ paths: get: operationId: getUsersOfScenario parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Scenario ID in: path name: scenarioID @@ -1964,6 +1876,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get users of a scenario tags: - scenarios @@ -1981,11 +1895,6 @@ paths: name: configID required: true type: string - - description: Authorization token - in: header - name: Authorization - required: true - type: string produces: - application/json responses: @@ -2005,6 +1914,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all signals of one direction tags: - signals @@ -2013,11 +1924,6 @@ paths: - application/json operationId: AddSignal parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: A signal to be added to the component configuration incl. direction and config ID to which signal shall be added in: body @@ -2049,6 +1955,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a signal to a signal mapping of a component configuration tags: - signals @@ -2056,11 +1964,6 @@ paths: delete: operationId: deleteSignal parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: ID of signal to be deleted in: path name: signalID @@ -2089,17 +1992,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a signal tags: - signals get: operationId: getSignal parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: ID of signal to be obtained in: path name: signalID @@ -2128,17 +2028,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get a signal tags: - signals put: operationId: updateSignal parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: A signal to be updated in: body name: inputSignal @@ -2174,18 +2071,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a signal tags: - signals /users: get: operationId: GetUsers - parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string produces: - application/json responses: @@ -2205,6 +2098,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all users tags: - users @@ -2220,11 +2115,6 @@ paths: schema: $ref: '#/definitions/user.addUserRequest' type: object - - description: Authorization token - in: header - name: Authorization - required: true - type: string produces: - application/json responses: @@ -2244,6 +2134,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a user tags: - users @@ -2251,11 +2143,6 @@ paths: delete: operationId: DeleteUser parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: User ID in: path name: userID @@ -2280,17 +2167,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a user tags: - users get: operationId: GetUser parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: User ID in: path name: userID @@ -2319,6 +2203,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get user tags: - users @@ -2327,11 +2213,6 @@ paths: - application/json operationId: UpdateUser parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: User to be updated (anything except for ID can be changed, role can only be change by admin) in: body @@ -2372,6 +2253,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a user tags: - users @@ -2379,11 +2262,6 @@ paths: get: operationId: getWidgets parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Dashboard ID in: query name: dashboardID @@ -2408,6 +2286,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get all widgets of dashboard tags: - widgets @@ -2416,11 +2296,6 @@ paths: - application/json operationId: addWidget parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Widget to be added incl. ID of dashboard in: body name: inputWidget @@ -2451,6 +2326,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Add a widget to a dashboard tags: - widgets @@ -2458,11 +2335,6 @@ paths: delete: operationId: deleteWidget parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Widget ID in: path name: widgetID @@ -2491,17 +2363,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Delete a widget tags: - widgets get: operationId: getWidget parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Widget ID in: path name: widgetID @@ -2530,6 +2399,8 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Get a widget tags: - widgets @@ -2538,11 +2409,6 @@ paths: - application/json operationId: updateWidget parameters: - - description: Authorization token - in: header - name: Authorization - required: true - type: string - description: Widget to be updated in: body name: inputWidget @@ -2578,7 +2444,14 @@ paths: description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' + security: + - Bearer: [] summary: Update a widget tags: - widgets +securityDefinitions: + Bearer: + in: header + name: Authorization + type: apiKey swagger: "2.0" diff --git a/routes/component-configuration/config_endpoints.go b/routes/component-configuration/config_endpoints.go index 23309b4..82c267f 100644 --- a/routes/component-configuration/config_endpoints.go +++ b/routes/component-configuration/config_endpoints.go @@ -48,9 +48,9 @@ func RegisterComponentConfigurationEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID query int true "Scenario ID" // @Router /configs [get] +// @Security Bearer func getConfigs(c *gin.Context) { ok, so := scenario.CheckPermissions(c, database.Read, "query", -1) @@ -78,9 +78,9 @@ func getConfigs(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputConfig body component_configuration.addConfigRequest true "component configuration to be added incl. IDs of scenario and IC" // @Router /configs [post] +// @Security Bearer func addConfig(c *gin.Context) { // Bind the request to JSON @@ -125,10 +125,10 @@ func addConfig(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputConfig body component_configuration.updateConfigRequest true "component configuration to be updated" // @Param configID path int true "Config ID" // @Router /configs/{configID} [put] +// @Security Bearer func updateConfig(c *gin.Context) { ok, oldConfig := CheckPermissions(c, database.Update, "path", -1) @@ -170,9 +170,9 @@ func updateConfig(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param configID path int true "Config ID" // @Router /configs/{configID} [get] +// @Security Bearer func getConfig(c *gin.Context) { ok, m := CheckPermissions(c, database.Read, "path", -1) @@ -193,9 +193,9 @@ func getConfig(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param configID path int true "Config ID" // @Router /configs/{configID} [delete] +// @Security Bearer func deleteConfig(c *gin.Context) { ok, m := CheckPermissions(c, database.Delete, "path", -1) diff --git a/routes/dashboard/dashboard_endpoints.go b/routes/dashboard/dashboard_endpoints.go index 0e9b313..dc9a98b 100644 --- a/routes/dashboard/dashboard_endpoints.go +++ b/routes/dashboard/dashboard_endpoints.go @@ -49,9 +49,9 @@ func RegisterDashboardEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID query int true "Scenario ID" // @Router /dashboards [get] +// @Security Bearer func getDashboards(c *gin.Context) { ok, sim := scenario.CheckPermissions(c, database.Read, "query", -1) @@ -79,9 +79,9 @@ func getDashboards(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputDab body dashboard.addDashboardRequest true "Dashboard to be added incl. ID of Scenario" // @Router /dashboards [post] +// @Security Bearer func addDashboard(c *gin.Context) { // bind request to JSON @@ -125,10 +125,10 @@ func addDashboard(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputDab body dashboard.updateDashboardRequest true "Dashboard to be updated" // @Param dashboardID path int true "Dashboard ID" // @Router /dashboards/{dashboardID} [put] +// @Security Bearer func updateDashboard(c *gin.Context) { ok, oldDashboard := CheckPermissions(c, database.Update, "path", -1) @@ -168,9 +168,9 @@ func updateDashboard(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param dashboardID path int true "Dashboard ID" // @Router /dashboards/{dashboardID} [get] +// @Security Bearer func getDashboard(c *gin.Context) { ok, dab := CheckPermissions(c, database.Read, "path", -1) @@ -191,9 +191,9 @@ func getDashboard(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param dashboardID path int true "Dashboard ID" // @Router /dashboards/{dashboardID} [delete] +// @Security Bearer func deleteDashboard(c *gin.Context) { ok, dab := CheckPermissions(c, database.Delete, "path", -1) if !ok { diff --git a/routes/file/file_endpoints.go b/routes/file/file_endpoints.go index 39488cf..ba52a9e 100644 --- a/routes/file/file_endpoints.go +++ b/routes/file/file_endpoints.go @@ -48,9 +48,9 @@ func RegisterFileEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID query int true "Scenario ID" // @Router /files [get] +// @Security Bearer func getFiles(c *gin.Context) { ok, so := scenario.CheckPermissions(c, database.Read, "query", -1) @@ -79,15 +79,16 @@ func getFiles(c *gin.Context) { // @Accept gif // @Accept model/x-cim // @Accept model/x-cim.zip +// @Accept multipart/form-data // @Success 200 {object} docs.ResponseFile "File that was added" // @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputFile formData file true "File to be uploaded" // @Param scenarioID query int true "ID of scenario to which file shall be added" // @Router /files [post] +// @Security Bearer func addFile(c *gin.Context) { ok, so := scenario.CheckPermissions(c, database.Read, "query", -1) @@ -125,9 +126,9 @@ func addFile(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param fileID path int true "ID of the file to download" // @Router /files/{fileID} [get] +// @Security Bearer func getFile(c *gin.Context) { // check access @@ -151,15 +152,16 @@ func getFile(c *gin.Context) { // @Accept gif // @Accept model/x-cim // @Accept model/x-cim.zip +// @Accept multipart/form-data // @Success 200 {object} docs.ResponseFile "File that was updated" // @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputFile formData file true "File to be uploaded" // @Param fileID path int true "ID of the file to update" // @Router /files/{fileID} [put] +// @Security Bearer func updateFile(c *gin.Context) { // check access @@ -191,9 +193,9 @@ func updateFile(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param fileID path int true "ID of the file to update" // @Router /files/{fileID} [delete] +// @Security Bearer func deleteFile(c *gin.Context) { // check access diff --git a/routes/infrastructure-component/ic_endpoints.go b/routes/infrastructure-component/ic_endpoints.go index f50bf25..e3eec1c 100644 --- a/routes/infrastructure-component/ic_endpoints.go +++ b/routes/infrastructure-component/ic_endpoints.go @@ -47,8 +47,8 @@ func RegisterICEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Router /ic [get] +// @Security Bearer func getICs(c *gin.Context) { // Checking permission is not required here since READ access is independent of user's role @@ -73,9 +73,9 @@ func getICs(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputIC body infrastructure_component.addICRequest true "Infrastructure Component to be added" // @Router /ic [post] +// @Security Bearer func addIC(c *gin.Context) { ok, _ := CheckPermissions(c, database.ModelInfrastructureComponent, database.Create, false) @@ -118,10 +118,10 @@ func addIC(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputIC body infrastructure_component.updateICRequest true "InfrastructureComponent to be updated" // @Param ICID path int true "InfrastructureComponent ID" // @Router /ic/{ICID} [put] +// @Security Bearer func updateIC(c *gin.Context) { ok, oldIC := CheckPermissions(c, database.ModelInfrastructureComponent, database.Update, true) @@ -163,9 +163,9 @@ func updateIC(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param ICID path int true "Infrastructure Component ID" // @Router /ic/{ICID} [get] +// @Security Bearer func getIC(c *gin.Context) { ok, s := CheckPermissions(c, database.ModelInfrastructureComponent, database.Read, true) @@ -186,9 +186,9 @@ func getIC(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param ICID path int true "Infrastructure Component ID" // @Router /ic/{ICID} [delete] +// @Security Bearer func deleteIC(c *gin.Context) { ok, s := CheckPermissions(c, database.ModelInfrastructureComponent, database.Delete, true) @@ -214,9 +214,9 @@ func deleteIC(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param ICID path int true "Infrastructure Component ID" // @Router /ic/{ICID}/configs [get] +// @Security Bearer func getConfigsOfIC(c *gin.Context) { ok, s := CheckPermissions(c, database.ModelInfrastructureComponent, database.Read, true) diff --git a/routes/scenario/scenario_endpoints.go b/routes/scenario/scenario_endpoints.go index bcfd940..72d077b 100644 --- a/routes/scenario/scenario_endpoints.go +++ b/routes/scenario/scenario_endpoints.go @@ -51,8 +51,8 @@ func RegisterScenarioEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Router /scenarios [get] +// @Security Bearer func getScenarios(c *gin.Context) { // Checking permissions is not required here as read access is independent of user's role @@ -97,9 +97,9 @@ func getScenarios(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputScenario body scenario.addScenarioRequest true "Scenario to be added" // @Router /scenarios [post] +// @Security Bearer func addScenario(c *gin.Context) { ok, _ := CheckPermissions(c, database.Create, "none", -1) @@ -156,10 +156,10 @@ func addScenario(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputScenario body scenario.updateScenarioRequest true "Scenario to be updated" // @Param scenarioID path int true "Scenario ID" // @Router /scenarios/{scenarioID} [put] +// @Security Bearer func updateScenario(c *gin.Context) { ok, oldScenario := CheckPermissions(c, database.Update, "path", -1) @@ -201,9 +201,9 @@ func updateScenario(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID path int true "Scenario ID" // @Router /scenarios/{scenarioID} [get] +// @Security Bearer func getScenario(c *gin.Context) { ok, so := CheckPermissions(c, database.Read, "path", -1) @@ -224,9 +224,9 @@ func getScenario(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID path int true "Scenario ID" // @Router /scenarios/{scenarioID} [delete] +// @Security Bearer func deleteScenario(c *gin.Context) { ok, so := CheckPermissions(c, database.Delete, "path", -1) @@ -251,9 +251,9 @@ func deleteScenario(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID path int true "Scenario ID" // @Router /scenarios/{scenarioID}/users/ [get] +// @Security Bearer func getUsersOfScenario(c *gin.Context) { ok, so := CheckPermissions(c, database.Read, "path", -1) @@ -279,10 +279,10 @@ func getUsersOfScenario(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID path int true "Scenario ID" // @Param username query string true "User name" // @Router /scenarios/{scenarioID}/user [put] +// @Security Bearer func addUserToScenario(c *gin.Context) { ok, so := CheckPermissions(c, database.Update, "path", -1) @@ -320,10 +320,10 @@ func addUserToScenario(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param scenarioID path int true "Scenario ID" // @Param username query string true "User name" // @Router /scenarios/{scenarioID}/user [delete] +// @Security Bearer func deleteUserFromScenario(c *gin.Context) { ok, so := CheckPermissions(c, database.Update, "path", -1) diff --git a/routes/signal/signal_endpoints.go b/routes/signal/signal_endpoints.go index 4c21705..9bed08b 100644 --- a/routes/signal/signal_endpoints.go +++ b/routes/signal/signal_endpoints.go @@ -50,8 +50,8 @@ func RegisterSignalEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Router /signals [get] +// @Security Bearer func getSignals(c *gin.Context) { ok, m := component_configuration.CheckPermissions(c, database.Read, "query", -1) @@ -90,9 +90,9 @@ func getSignals(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputSignal body signal.addSignalRequest true "A signal to be added to the component configuration incl. direction and config ID to which signal shall be added" // @Router /signals [post] +// @Security Bearer func addSignal(c *gin.Context) { var req addSignalRequest @@ -133,10 +133,10 @@ func addSignal(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputSignal body signal.updateSignalRequest true "A signal to be updated" // @Param signalID path int true "ID of signal to be updated" // @Router /signals/{signalID} [put] +// @Security Bearer func updateSignal(c *gin.Context) { ok, oldSignal := checkPermissions(c, database.Delete) if !ok { @@ -176,9 +176,9 @@ func updateSignal(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param signalID path int true "ID of signal to be obtained" // @Router /signals/{signalID} [get] +// @Security Bearer func getSignal(c *gin.Context) { ok, sig := checkPermissions(c, database.Delete) if !ok { @@ -198,9 +198,9 @@ func getSignal(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param signalID path int true "ID of signal to be deleted" // @Router /signals/{signalID} [delete] +// @Security Bearer func deleteSignal(c *gin.Context) { ok, sig := checkPermissions(c, database.Delete) diff --git a/routes/user/user_endpoints.go b/routes/user/user_endpoints.go index dc6c25a..ba133fa 100644 --- a/routes/user/user_endpoints.go +++ b/routes/user/user_endpoints.go @@ -54,8 +54,8 @@ func RegisterUserEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Router /users [get] +// @Security Bearer func getUsers(c *gin.Context) { err := database.ValidateRole(c, database.ModelUsers, database.Read) @@ -84,8 +84,8 @@ func getUsers(c *gin.Context) { // @Failure 400 {object} docs.ResponseError "Bad request" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Router /users [post] +// @Security Bearer func addUser(c *gin.Context) { err := database.ValidateRole(c, database.ModelUser, database.Create) @@ -144,10 +144,10 @@ func addUser(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputUser body user.updateUserRequest true "User to be updated (anything except for ID can be changed, role can only be change by admin)" // @Param userID path int true "User ID" // @Router /users/{userID} [put] +// @Security Bearer func updateUser(c *gin.Context) { // no need to validate the role since updating a single user is role independent @@ -235,9 +235,9 @@ func updateUser(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param userID path int true "User ID" // @Router /users/{userID} [get] +// @Security Bearer func getUser(c *gin.Context) { // role validation not needed because updating a single user is role-independent @@ -277,9 +277,9 @@ func getUser(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param userID path int true "User ID" // @Router /users/{userID} [delete] +// @Security Bearer func deleteUser(c *gin.Context) { err := database.ValidateRole(c, database.ModelUser, database.Delete) diff --git a/routes/widget/widget_endpoints.go b/routes/widget/widget_endpoints.go index 644a4ce..4bdaaf4 100644 --- a/routes/widget/widget_endpoints.go +++ b/routes/widget/widget_endpoints.go @@ -48,9 +48,9 @@ func RegisterWidgetEndpoints(r *gin.RouterGroup) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param dashboardID query int true "Dashboard ID" // @Router /widgets [get] +// @Security Bearer func getWidgets(c *gin.Context) { ok, dab := dashboard.CheckPermissions(c, database.Read, "query", -1) @@ -78,9 +78,9 @@ func getWidgets(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputWidget body widget.addWidgetRequest true "Widget to be added incl. ID of dashboard" // @Router /widgets [post] +// @Security Bearer func addWidget(c *gin.Context) { var req addWidgetRequest @@ -122,10 +122,10 @@ func addWidget(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param inputWidget body widget.updateWidgetRequest true "Widget to be updated" // @Param widgetID path int true "Widget ID" // @Router /widgets/{widgetID} [put] +// @Security Bearer func updateWidget(c *gin.Context) { ok, oldWidget := CheckPermissions(c, database.Update, -1) @@ -166,9 +166,9 @@ func updateWidget(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param widgetID path int true "Widget ID" // @Router /widgets/{widgetID} [get] +// @Security Bearer func getWidget(c *gin.Context) { ok, w := CheckPermissions(c, database.Read, -1) @@ -189,9 +189,9 @@ func getWidget(c *gin.Context) { // @Failure 404 {object} docs.ResponseError "Not found" // @Failure 422 {object} docs.ResponseError "Unprocessable entity" // @Failure 500 {object} docs.ResponseError "Internal server error" -// @Param Authorization header string true "Authorization token" // @Param widgetID path int true "Widget ID" // @Router /widgets/{widgetID} [delete] +// @Security Bearer func deleteWidget(c *gin.Context) { ok, w := CheckPermissions(c, database.Delete, -1) diff --git a/start.go b/start.go index 8bfbc68..c229163 100644 --- a/start.go +++ b/start.go @@ -57,14 +57,17 @@ func addData(router *gin.Engine, mode string, basePath string) error { // @title VILLASweb Backend API // @version 2.0 -// @description This is the VILLASweb Backend API v2.0. -// @description Parts of this API are still in development. Please check the [VILLASweb-backend-go repository](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) for more information. +// @description This is the [VILLASweb Backend](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) API v2.0. // @description This documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework. +// @description Authentication: Use the authenticate endpoint below to obtain a token for your user account, copy the token into to the value field of the dialog showing up for the green Authorize button below and confirm with Done. // @contact.name Sonja Happ // @contact.email sonja.happ@eonerc.rwth-aachen.de // @license.name GNU GPL 3.0 // @license.url http://www.gnu.de/documents/gpl-3.0.en.html // @BasePath /api/v2 +// @securityDefinitions.apikey Bearer +// @in header +// @name Authorization func main() { log.Println("Starting VILLASweb-backend-go")