{ "swagger": "2.0", "info": { "description": "ant-forum api", "title": "ant-forum API", "contact": { "name": "ant", "url": "http://www.swagger.io/support", "email": "2929712050@qq.com" }, "license": {}, "version": "1.0" }, "host": "localhost:8080", "paths": { "/sd/cpu": { "get": { "description": "Checks the cpu usage", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "sd" ], "summary": "Checks the cpu usage", "responses": { "200": { "description": "CRITICAL - Load average: 1.78, 1.99, 2.02 | Cores: 2", "schema": { "type": "string" } } } } }, "/sd/disk": { "get": { "description": "Checks the disk usage", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "sd" ], "summary": "Checks the disk usage", "responses": { "200": { "description": "OK - Free space: 17233MB (16GB) / 51200MB (50GB) | Used: 33%", "schema": { "type": "string" } } } } }, "/sd/health": { "get": { "description": "Shows OK as the ping-pong result", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "sd" ], "summary": "Shows OK as the ping-pong result", "responses": { "200": { "description": "OK", "schema": { "type": "string" } } } } }, "/sd/ram": { "get": { "description": "Checks the ram usage", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "sd" ], "summary": "Checks the ram usage", "responses": { "200": { "description": "OK - Free space: 402MB (0GB) / 8192MB (8GB) | Used: 4%", "schema": { "type": "string" } } } } }, "/v1/articles": { "get": { "description": "获取文章列表", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "articles" ], "summary": "获取文章列表", "parameters": [ { "type": "integer", "description": "Offset", "name": "offset", "in": "query", "required": true }, { "type": "integer", "description": "Limit", "name": "limit", "in": "query", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"totalCount\":1,\"list\":[]", "schema": { "$ref": "#/definitions/articles.ListResponse" } } } }, "post": { "description": "创建文章", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "articles" ], "summary": "创建文章", "parameters": [ { "description": "创建文章", "name": "articles", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/articles.CreateRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } }, "/v1/articles/{id}": { "get": { "description": "用文章id获取单篇文章信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "articles" ], "summary": "用文章id获取单篇信息", "parameters": [ { "type": "string", "description": "Id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{}}", "schema": { "$ref": "#/definitions/articles.GetArticleInfo" } } } }, "delete": { "description": "根据标签id删除文章", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "articles" ], "summary": "根据标签id删除文章", "parameters": [ { "type": "integer", "description": "文章的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } }, "/v1/auth/info": { "get": { "description": "Get an user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "user" ], "summary": "Get an user", "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"username\":\"kong\"}}", "schema": { "$ref": "#/definitions/model.UserInfo" } } } } }, "/v1/categories": { "get": { "description": "获取分类列表", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "categories" ], "summary": "获取分类列表", "parameters": [ { "type": "integer", "description": "Offset", "name": "offset", "in": "query", "required": true }, { "type": "integer", "description": "Limit", "name": "limit", "in": "query", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"totalCount\":1,\"list\":[{\"id\":0,\"category_name\":\"前端\"}]}}", "schema": { "$ref": "#/definitions/categories.ListResponse" } } } }, "post": { "description": "创建分类", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "categories" ], "summary": "创建分类", "parameters": [ { "description": "创建新标签", "name": "tags", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/categories.CreateRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"category_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/categories.CreateResponse" } } } } }, "/v1/categories/{id}": { "get": { "description": "用分类id获取单个分类信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "categories" ], "summary": "用分类id获取单个分类信息", "parameters": [ { "type": "string", "description": "Id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"id\":0,\"category_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/model.CategoryInfo" } } } }, "delete": { "description": "根据标签id删除分类", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "categories" ], "summary": "根据标签id删除分类", "parameters": [ { "type": "integer", "description": "标签数据的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } }, "/v1/login": { "post": { "description": "登录", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "login" ], "summary": "Login generates the authentication token", "parameters": [ { "description": "login", "name": "user", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/user.LoginRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MjgwMTY5MjIsImlkIjowLCJuYmYiOjE1MjgwMTY5MjIsInVzZXJuYW1lIjoiYWRtaW4ifQ.LjxrK9DuAwAzUD8-9v43NzWBN7HXsSLfebw92DKd1JQ\"}}", "schema": { "$ref": "#/definitions/user.LoginResponse" } } } } }, "/v1/menu": { "get": { "description": "获取菜单列表", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "menu" ], "summary": "获取菜单列表", "parameters": [ { "type": "integer", "description": "Offset", "name": "offset", "in": "query" }, { "type": "integer", "description": "Limit", "name": "limit", "in": "query" } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"totalCount\":1,\"list\":[{\"id\":0,\"tag_name\":\"前端\"}]}}", "schema": { "$ref": "#/definitions/menu.ListResponse" } } } }, "post": { "description": "创建菜单", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "menu" ], "summary": "创建菜单", "parameters": [ { "description": "创建新标签", "name": "menu", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/menu.CreateRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"tag_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/menu.CreateResponse" } } } } }, "/v1/menu/{id}": { "get": { "description": "获取单个菜单", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "menu" ], "summary": "获取单个菜单", "parameters": [ { "type": "integer", "description": "菜单数据的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"id\":0,\"category_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/model.MenuInfo" } } } }, "put": { "description": "更改菜单", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "menu" ], "summary": "更改菜单", "parameters": [ { "type": "integer", "description": "菜单数据的数据库id", "name": "id", "in": "path", "required": true }, { "description": "The user info", "name": "menu", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/model.MenuModel" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } }, "delete": { "description": "根据菜单id删除菜单", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "menu" ], "summary": "根据菜单id删除菜单", "parameters": [ { "type": "integer", "description": "菜单数据的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } }, "/v1/role": { "get": { "description": "获取角色列表", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "role" ], "summary": "获取角色列表", "parameters": [ { "type": "integer", "description": "Offset", "name": "offset", "in": "query" }, { "type": "integer", "description": "Limit", "name": "limit", "in": "query" } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"totalCount\":1,\"list\":[{\"id\":0,\"tag_name\":\"前端\"}]}}", "schema": { "$ref": "#/definitions/role.ListResponse" } } } }, "post": { "description": "创建角色", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "role" ], "summary": "创建角色", "parameters": [ { "description": "创建角色", "name": "role", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/role.CreateRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"tag_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/role.CreateResponse" } } } } }, "/v1/role/{id}": { "get": { "description": "获取单个角色", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "role" ], "summary": "获取单个角色", "parameters": [ { "type": "integer", "description": "角色数据的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"id\":0,\"category_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/model.RoleInfo" } } } }, "put": { "description": "更新角色数据", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "role" ], "summary": "更新角色数据", "parameters": [ { "type": "integer", "description": "角色数据的数据库id", "name": "id", "in": "path", "required": true }, { "description": "role", "name": "role", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/model.RoleModel" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } }, "delete": { "description": "根据角色id删除角色", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "role" ], "summary": "根据角色id删除角色", "parameters": [ { "type": "integer", "description": "角色数据的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } }, "/v1/tags": { "get": { "description": "获取标签列表", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "tags" ], "summary": "获取标签列表", "parameters": [ { "type": "integer", "description": "Offset", "name": "offset", "in": "query" }, { "type": "integer", "description": "Limit", "name": "limit", "in": "query" } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"totalCount\":1,\"list\":[{\"id\":0,\"tag_name\":\"前端\"}]}}", "schema": { "$ref": "#/definitions/tags.ListResponse" } } } }, "post": { "description": "创建标签", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "tags" ], "summary": "创建标签", "parameters": [ { "description": "创建新标签", "name": "tags", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/tags.CreateRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"tag_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/tags.CreateResponse" } } } } }, "/v1/tags/{id}": { "get": { "description": "用标签id获取单个标签信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "tags" ], "summary": "用标签id获取单个标签信息", "parameters": [ { "type": "string", "description": "Id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"id\":0,\"tag_name\":\"前端\"}}", "schema": { "$ref": "#/definitions/model.TagInfo" } } } }, "delete": { "description": "根据标签id删除标签", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "tags" ], "summary": "根据标签id删除标签", "parameters": [ { "type": "integer", "description": "标签数据的数据库id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } }, "/v1/user": { "get": { "security": [ { "ApiKeyAuth": [] } ], "description": "List users", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "user" ], "summary": "List the users in the database", "parameters": [ { "type": "integer", "description": "Offset", "name": "offset", "in": "query", "required": true }, { "type": "integer", "description": "Limit", "name": "limit", "in": "query", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"totalCount\":1,\"userList\":[{\"id\":0,\"username\":\"admin\",\"random\":\"user 'admin' get random string 'EnqntiSig'\",\"password\":\"$2a$10$veGcArz47VGj7l9xN7g2iuT9TF21jLI1YGXarGzvARNdnt4inC9PG\",\"createdAt\":\"2018-05-28 00:25:33\",\"updatedAt\":\"2018-05-28 00:25:33\"}]}}", "schema": { "$ref": "#/definitions/user.ListResponse" } } } }, "post": { "description": "Add a new user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "user" ], "summary": "Add new user to the database", "parameters": [ { "description": "Create a new user", "name": "user", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/user.CreateRequest" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"username\":\"kong\"}}", "schema": { "$ref": "#/definitions/user.CreateResponse" } } } } }, "/v1/user/{id}": { "get": { "description": "Get an user by id", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "user" ], "summary": "Get an user by the user id", "parameters": [ { "type": "string", "description": "Id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":{\"username\":\"kong\"}}", "schema": { "$ref": "#/definitions/model.UserInfo" } } } }, "put": { "description": "Update a user by ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "user" ], "summary": "Update a user info by the user identifier", "parameters": [ { "type": "integer", "description": "The user's database id index num", "name": "id", "in": "path", "required": true }, { "description": "The user info", "name": "user", "in": "body", "required": true, "schema": { "type": "object", "$ref": "#/definitions/model.UserModel" } } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } }, "delete": { "description": "Delete user by ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "user" ], "summary": "Delete an user by the user identifier", "parameters": [ { "type": "integer", "description": "The user's database id index num", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "{\"code\":0,\"message\":\"OK\",\"data\":null}", "schema": { "$ref": "#/definitions/v1.Response" } } } } } }, "definitions": { "articles.CreateRequest": { "type": "object", "properties": { "category_id": { "type": "integer" }, "content": { "type": "string" }, "tag_id": { "type": "integer" }, "title": { "type": "string" }, "user_id": { "type": "integer" } } }, "articles.GetArticleInfo": { "type": "object", "properties": { "avatar": { "type": "string" }, "category_id": { "type": "integer" }, "category_name": { "type": "string" }, "content": { "type": "string" }, "created_at": { "type": "string" }, "id": { "type": "integer" }, "tag_id": { "type": "integer" }, "tag_name": { "type": "string" }, "title": { "type": "string" }, "update_at": { "type": "string" }, "user_id": { "type": "integer" }, "username": { "type": "string" } } }, "articles.ListResponse": { "type": "object", "properties": { "list": { "type": "array", "items": { "$ref": "#/definitions/model.ArticleInfo" } }, "totalCount": { "type": "integer" } } }, "categories.CreateRequest": { "type": "object", "properties": { "category_name": { "type": "string" } } }, "categories.CreateResponse": { "type": "object", "properties": { "category_name": { "type": "string" } } }, "categories.ListResponse": { "type": "object", "properties": { "list": { "type": "array", "items": { "$ref": "#/definitions/model.CategoryInfo" } }, "totalCount": { "type": "integer" } } }, "menu.CreateRequest": { "type": "object", "required": [ "method", "name", "path" ], "properties": { "method": { "type": "string" }, "name": { "type": "string" }, "path": { "type": "string" } } }, "menu.CreateResponse": { "type": "object", "properties": { "method": { "type": "string" }, "name": { "type": "string" }, "path": { "type": "string" } } }, "menu.ListResponse": { "type": "object", "properties": { "list": { "type": "array", "items": { "$ref": "#/definitions/model.MenuInfo" } }, "totalCount": { "type": "integer" } } }, "model.ArticleInfo": { "type": "object", "properties": { "avatar": { "type": "string" }, "category_id": { "type": "integer" }, "category_name": { "type": "string" }, "content": { "type": "string" }, "created_at": { "type": "string" }, "id": { "type": "integer" }, "tag_id": { "type": "integer" }, "tag_name": { "type": "string" }, "title": { "type": "string" }, "update_at": { "type": "string" }, "user_id": { "type": "integer" }, "username": { "type": "string" } } }, "model.CategoryInfo": { "type": "object", "properties": { "category_name": { "type": "string" }, "id": { "type": "integer" } } }, "model.MenuInfo": { "type": "object", "properties": { "id": { "type": "integer" }, "method": { "type": "string" }, "name": { "type": "string" }, "path": { "type": "string" } } }, "model.MenuModel": { "type": "object", "required": [ "method", "name", "path" ], "properties": { "method": { "type": "string" }, "name": { "type": "string" }, "path": { "type": "string" } } }, "model.RoleInfo": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" } } }, "model.RoleModel": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" } } }, "model.TagInfo": { "type": "object", "properties": { "id": { "type": "integer" }, "tag_name": { "type": "string" } } }, "model.UserInfo": { "type": "object", "properties": { "avatar": { "type": "string" }, "id": { "type": "integer" }, "username": { "type": "string" } } }, "model.UserModel": { "type": "object", "required": [ "avatar", "password", "username" ], "properties": { "avatar": { "type": "string" }, "password": { "type": "string" }, "username": { "type": "string" } } }, "role.CreateRequest": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" } } }, "role.CreateResponse": { "type": "object", "properties": { "name": { "type": "string" } } }, "role.ListResponse": { "type": "object", "properties": { "list": { "type": "array", "items": { "$ref": "#/definitions/model.RoleInfo" } }, "totalCount": { "type": "integer" } } }, "tags.CreateRequest": { "type": "object", "required": [ "tag_name" ], "properties": { "tag_name": { "type": "string" } } }, "tags.CreateResponse": { "type": "object", "properties": { "tag_name": { "type": "string" } } }, "tags.ListResponse": { "type": "object", "properties": { "list": { "type": "array", "items": { "$ref": "#/definitions/model.TagInfo" } }, "totalCount": { "type": "integer" } } }, "user.CreateRequest": { "type": "object", "properties": { "password": { "type": "string" }, "username": { "type": "string" } } }, "user.CreateResponse": { "type": "object", "properties": { "username": { "type": "string" } } }, "user.ListResponse": { "type": "object", "properties": { "totalCount": { "type": "integer" }, "userList": { "type": "array", "items": { "$ref": "#/definitions/model.UserInfo" } } } }, "user.LoginRequest": { "type": "object", "properties": { "password": { "type": "string" }, "username": { "type": "string" } } }, "user.LoginResponse": { "type": "object", "properties": { "username": { "type": "string" } } }, "v1.Response": { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object" }, "message": { "type": "string" } } } }, "securityDefinitions": { "ApiKeyAuth": { "type": "apiKey", "name": "Authorization", "in": "header" } } }