Commit c4d7fc94 authored by Sonja Happ's avatar Sonja Happ
Browse files

add APIkey-based authentication to swagger documentation

parent 87894670
......@@ -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)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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)
......
......@@ -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 {
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment