From f0d7d79e0f891672d939d2e1de2ad55f548ffdb4 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 20 Dec 2025 17:36:24 +0200 Subject: [PATCH] add swagger --- api/router.go | 7 +- docs/docs.go | 959 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 930 ++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 625 ++++++++++++++++++++++++++++++ 4 files changed, 2520 insertions(+), 1 deletion(-) create mode 100644 docs/docs.go create mode 100644 docs/swagger.json create mode 100644 docs/swagger.yaml diff --git a/api/router.go b/api/router.go index 87e1b4a..5be8494 100644 --- a/api/router.go +++ b/api/router.go @@ -11,12 +11,14 @@ import ( api_acladmin "git.oblat.lv/alex/triggerssmith/api/acl_admin" api_auth "git.oblat.lv/alex/triggerssmith/api/auth" api_block "git.oblat.lv/alex/triggerssmith/api/block" + _ "git.oblat.lv/alex/triggerssmith/docs" "git.oblat.lv/alex/triggerssmith/internal/acl" "git.oblat.lv/alex/triggerssmith/internal/auth" "git.oblat.lv/alex/triggerssmith/internal/config" "git.oblat.lv/alex/triggerssmith/internal/vars" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" + httpSwagger "github.com/swaggo/http-swagger" ) type Router struct { @@ -66,7 +68,7 @@ func (r *Router) MustRoute() chi.Router { slog.String("dir", r.cfg.Server.StaticConfig.Dir), slog.String("index_file", r.cfg.Server.StaticConfig.IndexFile), ) - r.r.Get("/", func(w http.ResponseWriter, req *http.Request) { + r.r.Get("/*", func(w http.ResponseWriter, req *http.Request) { http.ServeFile(w, req, filepath.Join(r.cfg.Server.StaticConfig.Dir, r.cfg.Server.StaticConfig.IndexFile)) }) fs := http.FileServer(http.Dir(r.cfg.Server.StaticConfig.Dir)) @@ -82,6 +84,9 @@ func (r *Router) MustRoute() chi.Router { } r.r.Route("/api", func(api chi.Router) { + api.Get("/swagger/*", httpSwagger.Handler( + httpSwagger.URL("/api/swagger/doc.json"), + )) api.Route("/block", api_block.MustRoute(r.cfg)) authRoute := api_auth.MustRoute(r.cfg, r.authService) api.Route("/auth", authRoute) diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..f4fe8fb --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,959 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/acl/resources": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Get all resources", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Create resource", + "parameters": [ + { + "description": "Resource", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceErrorInvalidResourceKey" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceErrorResourceAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + }, + "/api/acl/resources/{resourceId}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Get resource by ID", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Resource ID", + "name": "resourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.getResourceResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.getResourceErrorInvalidResourceID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.getResourceErrorResourceNotFound" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Delete resource", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Resource ID", + "name": "resourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteResourceErrorInvalidResourceID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteResourceErrorResourceNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteResourceErrorResourceInUse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Update resource", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Resource ID", + "name": "resourceId", + "in": "path", + "required": true + }, + { + "description": "Resource", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceErrorInvalidResourceKey" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceErrorResourceNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceErrorResourceKeyAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + }, + "/api/acl/roles": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Get all roles", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Create role", + "parameters": [ + { + "description": "Role", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInvalidRequestBody" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleErrorInvalidRoleName" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleErrorRoleAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + }, + "/api/acl/roles/{roleId}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Get role by ID", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Role ID", + "name": "roleId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.getRoleResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.getRoleErrorInvalidRoleID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.getRoleErrorRoleNotFound" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Delete role", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Role ID", + "name": "roleId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteRoleErrorInvalidRoleID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteRoleErrorRoleNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteRoleErrorRoleInUse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Update role", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Role ID", + "name": "roleId", + "in": "path", + "required": true + }, + { + "description": "Role", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleErrorInvalidRoleName" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleErrorRoleNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleErrorRoleNameAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + } + }, + "definitions": { + "api_acladmin.createResourceErrorInvalidResourceKey": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid resource key" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_RESOURCE" + } + } + }, + "api_acladmin.createResourceErrorResourceAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource with key 'html.view' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_RESOURCE" + } + } + }, + "api_acladmin.createResourceRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.createResourceResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.createRoleErrorInvalidRoleName": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid role name" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_ROLE" + } + } + }, + "api_acladmin.createRoleErrorRoleAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role with name 'admin' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_ROLE" + } + } + }, + "api_acladmin.createRoleRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.createRoleResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.deleteResourceErrorInvalidResourceID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_RESOURCE_ID" + } + } + }, + "api_acladmin.deleteResourceErrorResourceInUse": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource with ID 123 is used and cannot be deleted" + }, + "error": { + "type": "string", + "example": "FAILED_TO_DELETE_RESOURCE" + } + } + }, + "api_acladmin.deleteResourceErrorResourceNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No resource with ID 123" + }, + "error": { + "type": "string", + "example": "RESOURCE_NOT_FOUND" + } + } + }, + "api_acladmin.deleteRoleErrorInvalidRoleID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_ROLE_ID" + } + } + }, + "api_acladmin.deleteRoleErrorRoleInUse": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role with ID 123 is assigned to users and cannot be deleted" + }, + "error": { + "type": "string", + "example": "FAILED_TO_DELETE_ROLE" + } + } + }, + "api_acladmin.deleteRoleErrorRoleNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No role with ID 123" + }, + "error": { + "type": "string", + "example": "ROLE_NOT_FOUND" + } + } + }, + "api_acladmin.errorInternalServerError": { + "type": "object", + "properties": { + "details": { + "type": "string" + }, + "error": { + "type": "string" + } + } + }, + "api_acladmin.errorInvalidRequestBody": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Request body is not valid JSON" + }, + "error": { + "type": "string", + "example": "INVALID_REQUEST_BODY" + } + } + }, + "api_acladmin.getResourceErrorInvalidResourceID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_RESOURCE_ID" + } + } + }, + "api_acladmin.getResourceErrorResourceNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No resource with ID 123" + }, + "error": { + "type": "string", + "example": "RESOURCE_NOT_FOUND" + } + } + }, + "api_acladmin.getResourceResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.getRoleErrorInvalidRoleID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_ROLE_ID" + } + } + }, + "api_acladmin.getRoleErrorRoleNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No role with ID 123" + }, + "error": { + "type": "string", + "example": "ROLE_NOT_FOUND" + } + } + }, + "api_acladmin.getRoleResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.updateResourceErrorInvalidResourceID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_RESOURCE_ID" + } + } + }, + "api_acladmin.updateResourceErrorInvalidResourceKey": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid resource key" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_RESOURCE" + } + } + }, + "api_acladmin.updateResourceErrorResourceKeyAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource with key 'html.view' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_RESOURCE" + } + } + }, + "api_acladmin.updateResourceErrorResourceNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No resource with ID 123" + }, + "error": { + "type": "string", + "example": "RESOURCE_NOT_FOUND" + } + } + }, + "api_acladmin.updateResourceRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.updateResourceResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.updateRoleErrorInvalidRoleID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_ROLE_ID" + } + } + }, + "api_acladmin.updateRoleErrorInvalidRoleName": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid role name" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_ROLE" + } + } + }, + "api_acladmin.updateRoleErrorRoleNameAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role with name 'admin' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_ROLE" + } + } + }, + "api_acladmin.updateRoleErrorRoleNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No role with ID 123" + }, + "error": { + "type": "string", + "example": "ROLE_NOT_FOUND" + } + } + }, + "api_acladmin.updateRoleRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.updateRoleResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..41c22c7 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,930 @@ +{ + "swagger": "2.0", + "info": { + "contact": {} + }, + "paths": { + "/api/acl/resources": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Get all resources", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Create resource", + "parameters": [ + { + "description": "Resource", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceErrorInvalidResourceKey" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.createResourceErrorResourceAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + }, + "/api/acl/resources/{resourceId}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Get resource by ID", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Resource ID", + "name": "resourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.getResourceResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.getResourceErrorInvalidResourceID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.getResourceErrorResourceNotFound" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Delete resource", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Resource ID", + "name": "resourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteResourceErrorInvalidResourceID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteResourceErrorResourceNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteResourceErrorResourceInUse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "resources" + ], + "summary": "Update resource", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Resource ID", + "name": "resourceId", + "in": "path", + "required": true + }, + { + "description": "Resource", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceErrorInvalidResourceKey" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceErrorResourceNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.updateResourceErrorResourceKeyAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + }, + "/api/acl/roles": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Get all roles", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Create role", + "parameters": [ + { + "description": "Role", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInvalidRequestBody" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleErrorInvalidRoleName" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.createRoleErrorRoleAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + }, + "/api/acl/roles/{roleId}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Get role by ID", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Role ID", + "name": "roleId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.getRoleResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.getRoleErrorInvalidRoleID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.getRoleErrorRoleNotFound" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Delete role", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Role ID", + "name": "roleId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteRoleErrorInvalidRoleID" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteRoleErrorRoleNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.deleteRoleErrorRoleInUse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + }, + "patch": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "roles" + ], + "summary": "Update role", + "parameters": [ + { + "type": "integer", + "example": 1, + "description": "Role ID", + "name": "roleId", + "in": "path", + "required": true + }, + { + "description": "Role", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleErrorInvalidRoleName" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleErrorRoleNotFound" + } + }, + "409": { + "description": "Conflict", + "schema": { + "$ref": "#/definitions/api_acladmin.updateRoleErrorRoleNameAlreadyExists" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api_acladmin.errorInternalServerError" + } + } + } + } + } + }, + "definitions": { + "api_acladmin.createResourceErrorInvalidResourceKey": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid resource key" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_RESOURCE" + } + } + }, + "api_acladmin.createResourceErrorResourceAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource with key 'html.view' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_RESOURCE" + } + } + }, + "api_acladmin.createResourceRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.createResourceResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.createRoleErrorInvalidRoleName": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid role name" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_ROLE" + } + } + }, + "api_acladmin.createRoleErrorRoleAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role with name 'admin' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_CREATE_ROLE" + } + } + }, + "api_acladmin.createRoleRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.createRoleResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.deleteResourceErrorInvalidResourceID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_RESOURCE_ID" + } + } + }, + "api_acladmin.deleteResourceErrorResourceInUse": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource with ID 123 is used and cannot be deleted" + }, + "error": { + "type": "string", + "example": "FAILED_TO_DELETE_RESOURCE" + } + } + }, + "api_acladmin.deleteResourceErrorResourceNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No resource with ID 123" + }, + "error": { + "type": "string", + "example": "RESOURCE_NOT_FOUND" + } + } + }, + "api_acladmin.deleteRoleErrorInvalidRoleID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_ROLE_ID" + } + } + }, + "api_acladmin.deleteRoleErrorRoleInUse": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role with ID 123 is assigned to users and cannot be deleted" + }, + "error": { + "type": "string", + "example": "FAILED_TO_DELETE_ROLE" + } + } + }, + "api_acladmin.deleteRoleErrorRoleNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No role with ID 123" + }, + "error": { + "type": "string", + "example": "ROLE_NOT_FOUND" + } + } + }, + "api_acladmin.errorInternalServerError": { + "type": "object", + "properties": { + "details": { + "type": "string" + }, + "error": { + "type": "string" + } + } + }, + "api_acladmin.errorInvalidRequestBody": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Request body is not valid JSON" + }, + "error": { + "type": "string", + "example": "INVALID_REQUEST_BODY" + } + } + }, + "api_acladmin.getResourceErrorInvalidResourceID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_RESOURCE_ID" + } + } + }, + "api_acladmin.getResourceErrorResourceNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No resource with ID 123" + }, + "error": { + "type": "string", + "example": "RESOURCE_NOT_FOUND" + } + } + }, + "api_acladmin.getResourceResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.getRoleErrorInvalidRoleID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_ROLE_ID" + } + } + }, + "api_acladmin.getRoleErrorRoleNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No role with ID 123" + }, + "error": { + "type": "string", + "example": "ROLE_NOT_FOUND" + } + } + }, + "api_acladmin.getRoleResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.updateResourceErrorInvalidResourceID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_RESOURCE_ID" + } + } + }, + "api_acladmin.updateResourceErrorInvalidResourceKey": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid resource key" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_RESOURCE" + } + } + }, + "api_acladmin.updateResourceErrorResourceKeyAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Resource with key 'html.view' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_RESOURCE" + } + } + }, + "api_acladmin.updateResourceErrorResourceNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No resource with ID 123" + }, + "error": { + "type": "string", + "example": "RESOURCE_NOT_FOUND" + } + } + }, + "api_acladmin.updateResourceRequest": { + "type": "object", + "properties": { + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.updateResourceResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "key": { + "type": "string", + "example": "html.view" + } + } + }, + "api_acladmin.updateRoleErrorInvalidRoleID": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role ID must be positive integer" + }, + "error": { + "type": "string", + "example": "INVALID_ROLE_ID" + } + } + }, + "api_acladmin.updateRoleErrorInvalidRoleName": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Invalid role name" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_ROLE" + } + } + }, + "api_acladmin.updateRoleErrorRoleNameAlreadyExists": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "Role with name 'admin' already exists" + }, + "error": { + "type": "string", + "example": "FAILED_TO_UPDATE_ROLE" + } + } + }, + "api_acladmin.updateRoleErrorRoleNotFound": { + "type": "object", + "properties": { + "details": { + "type": "string", + "example": "No role with ID 123" + }, + "error": { + "type": "string", + "example": "ROLE_NOT_FOUND" + } + } + }, + "api_acladmin.updateRoleRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "admin" + } + } + }, + "api_acladmin.updateRoleResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "name": { + "type": "string", + "example": "admin" + } + } + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..45e0c12 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,625 @@ +definitions: + api_acladmin.createResourceErrorInvalidResourceKey: + properties: + details: + example: Invalid resource key + type: string + error: + example: FAILED_TO_CREATE_RESOURCE + type: string + type: object + api_acladmin.createResourceErrorResourceAlreadyExists: + properties: + details: + example: Resource with key 'html.view' already exists + type: string + error: + example: FAILED_TO_CREATE_RESOURCE + type: string + type: object + api_acladmin.createResourceRequest: + properties: + key: + example: html.view + type: string + type: object + api_acladmin.createResourceResponse: + properties: + id: + example: 1 + type: integer + key: + example: html.view + type: string + type: object + api_acladmin.createRoleErrorInvalidRoleName: + properties: + details: + example: Invalid role name + type: string + error: + example: FAILED_TO_CREATE_ROLE + type: string + type: object + api_acladmin.createRoleErrorRoleAlreadyExists: + properties: + details: + example: Role with name 'admin' already exists + type: string + error: + example: FAILED_TO_CREATE_ROLE + type: string + type: object + api_acladmin.createRoleRequest: + properties: + name: + example: admin + type: string + type: object + api_acladmin.createRoleResponse: + properties: + id: + example: 1 + type: integer + name: + example: admin + type: string + type: object + api_acladmin.deleteResourceErrorInvalidResourceID: + properties: + details: + example: Resource ID must be positive integer + type: string + error: + example: INVALID_RESOURCE_ID + type: string + type: object + api_acladmin.deleteResourceErrorResourceInUse: + properties: + details: + example: Resource with ID 123 is used and cannot be deleted + type: string + error: + example: FAILED_TO_DELETE_RESOURCE + type: string + type: object + api_acladmin.deleteResourceErrorResourceNotFound: + properties: + details: + example: No resource with ID 123 + type: string + error: + example: RESOURCE_NOT_FOUND + type: string + type: object + api_acladmin.deleteRoleErrorInvalidRoleID: + properties: + details: + example: Role ID must be positive integer + type: string + error: + example: INVALID_ROLE_ID + type: string + type: object + api_acladmin.deleteRoleErrorRoleInUse: + properties: + details: + example: Role with ID 123 is assigned to users and cannot be deleted + type: string + error: + example: FAILED_TO_DELETE_ROLE + type: string + type: object + api_acladmin.deleteRoleErrorRoleNotFound: + properties: + details: + example: No role with ID 123 + type: string + error: + example: ROLE_NOT_FOUND + type: string + type: object + api_acladmin.errorInternalServerError: + properties: + details: + type: string + error: + type: string + type: object + api_acladmin.errorInvalidRequestBody: + properties: + details: + example: Request body is not valid JSON + type: string + error: + example: INVALID_REQUEST_BODY + type: string + type: object + api_acladmin.getResourceErrorInvalidResourceID: + properties: + details: + example: Resource ID must be positive integer + type: string + error: + example: INVALID_RESOURCE_ID + type: string + type: object + api_acladmin.getResourceErrorResourceNotFound: + properties: + details: + example: No resource with ID 123 + type: string + error: + example: RESOURCE_NOT_FOUND + type: string + type: object + api_acladmin.getResourceResponse: + properties: + id: + example: 1 + type: integer + key: + example: html.view + type: string + type: object + api_acladmin.getRoleErrorInvalidRoleID: + properties: + details: + example: Role ID must be positive integer + type: string + error: + example: INVALID_ROLE_ID + type: string + type: object + api_acladmin.getRoleErrorRoleNotFound: + properties: + details: + example: No role with ID 123 + type: string + error: + example: ROLE_NOT_FOUND + type: string + type: object + api_acladmin.getRoleResponse: + properties: + id: + example: 1 + type: integer + name: + example: admin + type: string + type: object + api_acladmin.updateResourceErrorInvalidResourceID: + properties: + details: + example: Resource ID must be positive integer + type: string + error: + example: INVALID_RESOURCE_ID + type: string + type: object + api_acladmin.updateResourceErrorInvalidResourceKey: + properties: + details: + example: Invalid resource key + type: string + error: + example: FAILED_TO_UPDATE_RESOURCE + type: string + type: object + api_acladmin.updateResourceErrorResourceKeyAlreadyExists: + properties: + details: + example: Resource with key 'html.view' already exists + type: string + error: + example: FAILED_TO_UPDATE_RESOURCE + type: string + type: object + api_acladmin.updateResourceErrorResourceNotFound: + properties: + details: + example: No resource with ID 123 + type: string + error: + example: RESOURCE_NOT_FOUND + type: string + type: object + api_acladmin.updateResourceRequest: + properties: + key: + example: html.view + type: string + type: object + api_acladmin.updateResourceResponse: + properties: + id: + example: 1 + type: integer + key: + example: html.view + type: string + type: object + api_acladmin.updateRoleErrorInvalidRoleID: + properties: + details: + example: Role ID must be positive integer + type: string + error: + example: INVALID_ROLE_ID + type: string + type: object + api_acladmin.updateRoleErrorInvalidRoleName: + properties: + details: + example: Invalid role name + type: string + error: + example: FAILED_TO_UPDATE_ROLE + type: string + type: object + api_acladmin.updateRoleErrorRoleNameAlreadyExists: + properties: + details: + example: Role with name 'admin' already exists + type: string + error: + example: FAILED_TO_UPDATE_ROLE + type: string + type: object + api_acladmin.updateRoleErrorRoleNotFound: + properties: + details: + example: No role with ID 123 + type: string + error: + example: ROLE_NOT_FOUND + type: string + type: object + api_acladmin.updateRoleRequest: + properties: + name: + example: admin + type: string + type: object + api_acladmin.updateRoleResponse: + properties: + id: + example: 1 + type: integer + name: + example: admin + type: string + type: object +info: + contact: {} +paths: + /api/acl/resources: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + properties: + id: + example: 1 + type: integer + key: + example: html.view + type: string + type: object + type: array + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Get all resources + tags: + - resources + post: + consumes: + - application/json + parameters: + - description: Resource + in: body + name: request + required: true + schema: + $ref: '#/definitions/api_acladmin.createResourceRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/api_acladmin.createResourceResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.createResourceErrorInvalidResourceKey' + "409": + description: Conflict + schema: + $ref: '#/definitions/api_acladmin.createResourceErrorResourceAlreadyExists' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Create resource + tags: + - resources + /api/acl/resources/{resourceId}: + delete: + parameters: + - description: Resource ID + example: 1 + in: path + name: resourceId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.deleteResourceErrorInvalidResourceID' + "404": + description: Not Found + schema: + $ref: '#/definitions/api_acladmin.deleteResourceErrorResourceNotFound' + "409": + description: Conflict + schema: + $ref: '#/definitions/api_acladmin.deleteResourceErrorResourceInUse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Delete resource + tags: + - resources + get: + parameters: + - description: Resource ID + example: 1 + in: path + name: resourceId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api_acladmin.getResourceResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.getResourceErrorInvalidResourceID' + "404": + description: Not Found + schema: + $ref: '#/definitions/api_acladmin.getResourceErrorResourceNotFound' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Get resource by ID + tags: + - resources + patch: + consumes: + - application/json + parameters: + - description: Resource ID + example: 1 + in: path + name: resourceId + required: true + type: integer + - description: Resource + in: body + name: request + required: true + schema: + $ref: '#/definitions/api_acladmin.updateResourceRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api_acladmin.updateResourceResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.updateResourceErrorInvalidResourceKey' + "404": + description: Not Found + schema: + $ref: '#/definitions/api_acladmin.updateResourceErrorResourceNotFound' + "409": + description: Conflict + schema: + $ref: '#/definitions/api_acladmin.updateResourceErrorResourceKeyAlreadyExists' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Update resource + tags: + - resources + /api/acl/roles: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + properties: + id: + example: 1 + type: integer + name: + example: admin + type: string + type: object + type: array + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Get all roles + tags: + - roles + post: + consumes: + - application/json + parameters: + - description: Role + in: body + name: request + required: true + schema: + $ref: '#/definitions/api_acladmin.createRoleRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/api_acladmin.createRoleResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.errorInvalidRequestBody' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/api_acladmin.createRoleErrorInvalidRoleName' + "409": + description: Conflict + schema: + $ref: '#/definitions/api_acladmin.createRoleErrorRoleAlreadyExists' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Create role + tags: + - roles + /api/acl/roles/{roleId}: + delete: + parameters: + - description: Role ID + example: 1 + in: path + name: roleId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.deleteRoleErrorInvalidRoleID' + "404": + description: Not Found + schema: + $ref: '#/definitions/api_acladmin.deleteRoleErrorRoleNotFound' + "409": + description: Conflict + schema: + $ref: '#/definitions/api_acladmin.deleteRoleErrorRoleInUse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Delete role + tags: + - roles + get: + parameters: + - description: Role ID + example: 1 + in: path + name: roleId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api_acladmin.getRoleResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.getRoleErrorInvalidRoleID' + "404": + description: Not Found + schema: + $ref: '#/definitions/api_acladmin.getRoleErrorRoleNotFound' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Get role by ID + tags: + - roles + patch: + consumes: + - application/json + parameters: + - description: Role ID + example: 1 + in: path + name: roleId + required: true + type: integer + - description: Role + in: body + name: request + required: true + schema: + $ref: '#/definitions/api_acladmin.updateRoleRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api_acladmin.updateRoleResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api_acladmin.updateRoleErrorInvalidRoleName' + "404": + description: Not Found + schema: + $ref: '#/definitions/api_acladmin.updateRoleErrorRoleNotFound' + "409": + description: Conflict + schema: + $ref: '#/definitions/api_acladmin.updateRoleErrorRoleNameAlreadyExists' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api_acladmin.errorInternalServerError' + summary: Update role + tags: + - roles +swagger: "2.0"