Files
knowledge-graph-agent/backend/docs/docs.go
T

747 lines
25 KiB
Go
Raw Normal View History

2026-04-13 16:16:39 +08:00
// 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": {
2026-04-15 14:24:39 +08:00
"/api/edges": {
"post": {
"description": "在知识图谱中创建一个新边(关系)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "创建边",
"parameters": [
{
"description": "边创建请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CreateEdgeRequest"
}
}
],
"responses": {
"200": {
"description": "创建成功",
"schema": {
"$ref": "#/definitions/models.EdgeResponse"
}
},
"400": {
"description": "请求错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"404": {
"description": "源节点或目标节点未找到",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"409": {
"description": "边已存在",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
},
"/api/edges/{id}": {
"delete": {
"description": "从知识图谱中删除指定的边",
"produces": [
"application/json"
],
"summary": "删除边",
"parameters": [
{
"type": "string",
"description": "边ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "删除成功",
"schema": {
"$ref": "#/definitions/models.DeleteResponse"
}
},
"404": {
"description": "边未找到",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
},
2026-04-13 16:16:39 +08:00
"/api/graph": {
"get": {
"description": "获取知识图谱的全部节点和边数据",
"produces": [
"application/json"
],
"summary": "获取图数据",
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/models.GraphData"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
},
"/api/graph/stats": {
"get": {
"description": "获取知识图谱的节点数、边数等统计信息",
"produces": [
"application/json"
],
"summary": "获取图统计信息",
"responses": {
"200": {
"description": "成功",
"schema": {
"type": "object",
"additionalProperties": true
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
},
2026-04-15 14:24:39 +08:00
"/api/nodes": {
"post": {
"description": "在知识图谱中创建一个新节点",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "创建节点",
"parameters": [
{
"description": "节点创建请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.CreateNodeRequest"
}
}
],
"responses": {
"200": {
"description": "创建成功",
"schema": {
"$ref": "#/definitions/models.Node"
}
},
"400": {
"description": "请求错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"409": {
"description": "节点已存在",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
},
2026-04-13 16:16:39 +08:00
"/api/nodes/{id}": {
"get": {
"description": "根据节点 ID 获取知识图谱中的节点详细信息",
"produces": [
"application/json"
],
"summary": "获取节点详情",
"parameters": [
{
"type": "string",
"description": "节点 ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/models.NodeResponse"
}
},
"400": {
"description": "请求错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"404": {
"description": "节点未找到",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
2026-04-15 14:24:39 +08:00
},
"put": {
"description": "更新知识图谱中指定节点的信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "更新节点",
"parameters": [
{
"type": "string",
"description": "节点ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "节点更新请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.UpdateNodeRequest"
}
}
],
"responses": {
"200": {
"description": "更新成功",
"schema": {
"$ref": "#/definitions/models.Node"
}
},
"400": {
"description": "请求错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"404": {
"description": "节点未找到",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
},
"delete": {
"description": "从知识图谱中删除指定节点及其相关的所有边",
"produces": [
"application/json"
],
"summary": "删除节点",
"parameters": [
{
"type": "string",
"description": "节点ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "删除成功",
"schema": {
"$ref": "#/definitions/models.DeleteResponse"
}
},
"404": {
"description": "节点未找到",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
2026-04-13 16:16:39 +08:00
}
},
"/api/nodes/{id}/neighbors": {
"get": {
"description": "根据节点 ID 获取其所有邻居节点及关联边",
"produces": [
"application/json"
],
"summary": "获取节点邻居",
"parameters": [
{
"type": "string",
"description": "节点 ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/models.NeighborResponse"
}
},
"400": {
"description": "请求错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"404": {
"description": "节点未找到",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
},
"/api/search": {
"get": {
"description": "根据关键词搜索知识图谱中的节点",
"produces": [
"application/json"
],
"summary": "搜索节点",
"parameters": [
{
"type": "string",
"description": "搜索关键词",
"name": "q",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
"$ref": "#/definitions/models.SearchResponse"
}
},
"400": {
"description": "请求错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/models.ErrorResponse"
}
}
}
}
}
},
"definitions": {
2026-04-15 14:24:39 +08:00
"models.CreateEdgeRequest": {
"type": "object",
"required": [
"id",
"label",
"source",
"target"
],
"properties": {
"id": {
"description": "边的唯一标识",
"type": "string",
"example": "edge_123"
},
"label": {
"description": "边的显示标签",
"type": "string",
"example": "包含"
},
"properties": {
"description": "自定义属性",
"type": "object",
"additionalProperties": true
},
"source": {
"description": "源节点ID",
"type": "string",
"example": "node_1"
},
"target": {
"description": "目标节点ID",
"type": "string",
"example": "node_2"
},
"type": {
"description": "边的类型(可选,默认为关系类型)",
"type": "string",
"example": "CONTAINS"
}
}
},
"models.CreateNodeRequest": {
"type": "object",
"required": [
"id",
"label",
"type"
],
"properties": {
"id": {
"description": "节点唯一标识",
"type": "string",
"example": "node_123"
},
"label": {
"description": "节点显示标签",
"type": "string",
"example": "人工智能"
},
"properties": {
"description": "自定义属性",
"type": "object",
"additionalProperties": true
},
"type": {
"description": "节点类型",
"type": "string",
"example": "概念"
},
"x": {
"description": "X坐标(可选)",
"type": "number",
"example": 100
},
"y": {
"description": "Y坐标(可选)",
"type": "number",
"example": 200
}
}
},
"models.DeleteResponse": {
"type": "object",
"properties": {
"id": {
"description": "被删除的实体ID(可选)",
"type": "string",
"example": "node_123"
},
"message": {
"description": "消息",
"type": "string",
"example": "节点已成功删除"
},
"success": {
"description": "是否成功",
"type": "boolean",
"example": true
}
}
},
2026-04-13 16:16:39 +08:00
"models.Edge": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"label": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"source": {
"type": "string"
},
"style": {
"type": "object",
"additionalProperties": true
},
"target": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
2026-04-15 14:24:39 +08:00
"models.EdgeResponse": {
"type": "object",
"properties": {
"id": {
"description": "边的ID",
"type": "string",
"example": "edge_123"
},
"label": {
"description": "边的显示标签",
"type": "string",
"example": "包含"
},
"properties": {
"description": "自定义属性",
"type": "object",
"additionalProperties": true
},
"source": {
"description": "源节点ID",
"type": "string",
"example": "node_1"
},
"target": {
"description": "目标节点ID",
"type": "string",
"example": "node_2"
},
"type": {
"description": "边的类型",
"type": "string",
"example": "CONTAINS"
}
}
},
2026-04-13 16:16:39 +08:00
"models.ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"models.GraphData": {
"type": "object",
"properties": {
"edges": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Edge"
}
},
"nodes": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Node"
}
}
}
},
"models.NeighborResponse": {
"type": "object",
"properties": {
"edges": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Edge"
}
},
"nodes": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Node"
}
}
}
},
"models.Node": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"label": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"style": {
"type": "object",
"additionalProperties": true
},
"type": {
"type": "string"
},
"x": {
"type": "number"
},
"y": {
"type": "number"
}
}
},
"models.NodeResponse": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "1"
},
"label": {
"type": "string",
"example": "人工智能"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"type": {
"type": "string",
"example": "概念"
}
}
},
"models.SearchResponse": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"results": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Node"
}
}
}
2026-04-15 14:24:39 +08:00
},
"models.UpdateNodeRequest": {
"type": "object",
"properties": {
"label": {
"description": "节点显示标签",
"type": "string",
"example": "机器学习"
},
"properties": {
"description": "自定义属性(更新)",
"type": "object",
"additionalProperties": true
},
"type": {
"description": "节点类型",
"type": "string",
"example": "工具"
},
"x": {
"description": "X坐标",
"type": "number",
"example": 150
},
"y": {
"description": "Y坐标",
"type": "number",
"example": 250
}
}
2026-04-13 16:16:39 +08:00
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0.0",
2026-04-13 16:24:25 +08:00
Host: "localhost:3001",
2026-04-13 16:16:39 +08:00
BasePath: "/",
Schemes: []string{},
Title: "知识图谱 API",
Description: "知识图谱后端服务,提供图数据查询、节点搜索等功能",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}