diff --git a/manager/handlers/permission.go b/manager/handlers/permission.go index d12d262da96..5cd34a220af 100644 --- a/manager/handlers/permission.go +++ b/manager/handlers/permission.go @@ -24,15 +24,14 @@ import ( // @Summary Get Permissions // @Description Get Permissions -// @Tags permission +// @Tags Permission // @Produce json -// @Success 200 {object} RoutesInfo -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Success 200 {object} []rbac.Permission +// @Failure 400 +// @Failure 500 // @Router /permissions [get] func (h *Handlers) GetPermissions(g *gin.Engine) func(ctx *gin.Context) { return func(ctx *gin.Context) { - permissions := h.Service.GetPermissions(g) - ctx.JSON(http.StatusOK, permissions) + ctx.JSON(http.StatusOK, h.Service.GetPermissions(g)) } } diff --git a/manager/handlers/role.go b/manager/handlers/role.go index 3425364f5eb..fb9e27c49de 100644 --- a/manager/handlers/role.go +++ b/manager/handlers/role.go @@ -25,12 +25,13 @@ import ( // @Summary Create Role // @Description Create Role by json config -// @Tags role +// @Tags Role // @Accept json // @Produce json +// @Param Role body types.CreateRoleRequest true "Role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /roles [post] func (h *Handlers) CreateRole(ctx *gin.Context) { var json types.CreateRoleRequest @@ -49,14 +50,14 @@ func (h *Handlers) CreateRole(ctx *gin.Context) { // @Summary Destroy Role // @Description Destroy role by json config -// @Tags permission +// @Tags Role // @Accept json // @Produce json // @Param role path string true "role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError -// @Router /role/:role [delete] +// @Failure 400 +// @Failure 500 +// @Router /roles/:role [delete] func (h *Handlers) DestroyRole(ctx *gin.Context) { var params types.RoleParams if err := ctx.ShouldBindUri(¶ms); err != nil { @@ -77,12 +78,13 @@ func (h *Handlers) DestroyRole(ctx *gin.Context) { // @Summary Get Role // @Description Get Role -// @Tags permission +// @Tags Role // @Accept json // @Produce json +// @Param role path string true "role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /roles/:role [get] func (h *Handlers) GetRole(ctx *gin.Context) { var params types.RoleParams @@ -96,12 +98,12 @@ func (h *Handlers) GetRole(ctx *gin.Context) { // @Summary Get Roles // @Description Get roles -// @Tags role +// @Tags Role // @Accept json // @Produce json // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /roles [get] func (h *Handlers) GetRoles(ctx *gin.Context) { roles := h.Service.GetRoles() @@ -110,14 +112,14 @@ func (h *Handlers) GetRoles(ctx *gin.Context) { // @Summary Add Permission For Role // @Description Add Permission by json config -// @Tags role +// @Tags Role // @Accept json // @Produce json // @Param Permission body types.AddPermissionForRoleRequest true "Permission" // @Param role path string true "role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /roles/:role/permissions [post] func (h *Handlers) AddPermissionForRole(ctx *gin.Context) { var params types.RoleParams @@ -145,14 +147,14 @@ func (h *Handlers) AddPermissionForRole(ctx *gin.Context) { // @Summary Update Role // @Description Remove Role Permission by json config -// @Tags role +// @Tags Role // @Accept json // @Produce json // @Param Permission body types.DeletePermissionForRoleRequest true "Permission" // @Param role path string true "role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /roles/:role/permissions [delete] func (h *Handlers) DeletePermissionForRole(ctx *gin.Context) { var params types.RoleParams diff --git a/manager/handlers/user.go b/manager/handlers/user.go index 6ac9cd7244f..fce32dfc557 100644 --- a/manager/handlers/user.go +++ b/manager/handlers/user.go @@ -86,8 +86,8 @@ func (h *Handlers) ResetPassword(ctx *gin.Context) { // @Produce json // @Param id path string true "id" // @Success 200 {object} []string -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /users/:id/roles [get] func (h *Handlers) GetRolesForUser(ctx *gin.Context) { var params types.UserParams @@ -107,14 +107,14 @@ func (h *Handlers) GetRolesForUser(ctx *gin.Context) { // @Summary Add Role For User // @Description add role to user by uri config -// @Tags users -// @Accept text +// @Tags Users +// @Accept json // @Produce json // @Param id path string true "id" // @Param role path string true "role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /users/:id/roles/:role [put] func (h *Handlers) AddRoleToUser(ctx *gin.Context) { var params types.AddRoleForUserParams @@ -136,14 +136,14 @@ func (h *Handlers) AddRoleToUser(ctx *gin.Context) { // @Summary Delete Role For User // @Description delete role by uri config -// @Tags users -// @Accept text +// @Tags Users +// @Accept json // @Produce json // @Param id path string true "id" // @Param role path string true "role" // @Success 200 -// @Failure 400 {object} HTTPError -// @Failure 500 {object} HTTPError +// @Failure 400 +// @Failure 500 // @Router /users/:id/roles/:role [delete] func (h *Handlers) DeleteRoleForUser(ctx *gin.Context) { var params types.DeleteRoleForUserParams diff --git a/manager/types/user.go b/manager/types/user.go index 4e8d04771fb..319a5857dd4 100644 --- a/manager/types/user.go +++ b/manager/types/user.go @@ -41,10 +41,10 @@ type SignUpRequest struct { type DeleteRoleForUserParams struct { ID uint `uri:"id" binding:"required"` - Role string `uri:"role" binding:"required,min=1"` + Role string `uri:"role" binding:"required"` } type AddRoleForUserParams struct { ID uint `uri:"id" binding:"required"` - Role string `uri:"role" binding:"required,min=1"` + Role string `uri:"role" binding:"required"` }