add swagger

This commit is contained in:
2025-12-20 17:36:24 +02:00
parent 78a8e46b3e
commit f0d7d79e0f
4 changed files with 2520 additions and 1 deletions

959
docs/docs.go Normal file
View File

@@ -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)
}

930
docs/swagger.json Normal file
View File

@@ -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"
}
}
}
}
}

625
docs/swagger.yaml Normal file
View File

@@ -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"