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

815 lines
26 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": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.CreateEdgeRequest"
2026-04-15 14:24:39 +08:00
}
}
],
"responses": {
"200": {
"description": "创建成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.EdgeResponse"
2026-04-15 14:24:39 +08:00
}
},
"400": {
"description": "请求错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"404": {
"description": "源节点或目标节点未找到",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"409": {
"description": "边已存在",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
}
}
}
},
"/api/edges/{id}": {
"delete": {
"description": "从知识图谱中删除指定的边",
"produces": [
"application/json"
],
"summary": "删除边",
"parameters": [
{
"type": "string",
"description": "边ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "删除成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.DeleteResponse"
2026-04-15 14:24:39 +08:00
}
},
"404": {
"description": "边未找到",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
}
}
}
},
2026-04-13 16:16:39 +08:00
"/api/graph": {
"get": {
"description": "获取知识图谱的全部节点和边数据",
"produces": [
"application/json"
],
"summary": "获取图数据",
"responses": {
"200": {
"description": "成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.GraphData"
2026-04-13 16:16:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
}
}
}
},
2026-04-15 14:52:33 +08:00
"/api/graph/simpleJson": {
"get": {
"description": "获取知识图谱的全部节点和边数据(仅保留核心信息,适合LLM处理)",
"produces": [
"application/json"
],
"summary": "获取简化图数据",
"responses": {
"200": {
"description": "成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.SimpleGraphData"
2026-04-15 14:52:33 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:52:33 +08:00
}
}
}
}
},
2026-04-13 16:16:39 +08:00
"/api/graph/stats": {
"get": {
"description": "获取知识图谱的节点数、边数等统计信息",
"produces": [
"application/json"
],
"summary": "获取图统计信息",
"responses": {
"200": {
"description": "成功",
"schema": {
"type": "object",
"additionalProperties": true
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
}
}
}
},
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": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.CreateNodeRequest"
2026-04-15 14:24:39 +08:00
}
}
],
"responses": {
"200": {
"description": "创建成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Node"
2026-04-15 14:24:39 +08:00
}
},
"400": {
"description": "请求错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"409": {
"description": "节点已存在",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
}
}
}
},
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": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.NodeResponse"
2026-04-13 16:16:39 +08:00
}
},
"400": {
"description": "请求错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
},
"404": {
"description": "节点未找到",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
}
}
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": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.UpdateNodeRequest"
2026-04-15 14:24:39 +08:00
}
}
],
"responses": {
"200": {
"description": "更新成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Node"
2026-04-15 14:24:39 +08:00
}
},
"400": {
"description": "请求错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"404": {
"description": "节点未找到",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
}
}
},
"delete": {
"description": "从知识图谱中删除指定节点及其相关的所有边",
"produces": [
"application/json"
],
"summary": "删除节点",
"parameters": [
{
"type": "string",
"description": "节点ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "删除成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.DeleteResponse"
2026-04-15 14:24:39 +08:00
}
},
"404": {
"description": "节点未找到",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-15 14:24:39 +08:00
}
}
}
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": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.NeighborResponse"
2026-04-13 16:16:39 +08:00
}
},
"400": {
"description": "请求错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
},
"404": {
"description": "节点未找到",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
}
}
}
},
"/api/search": {
"get": {
"description": "根据关键词搜索知识图谱中的节点",
"produces": [
"application/json"
],
"summary": "搜索节点",
"parameters": [
{
"type": "string",
"description": "搜索关键词",
"name": "q",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "成功",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.SearchResponse"
2026-04-13 16:16:39 +08:00
}
},
"400": {
"description": "请求错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
},
"500": {
"description": "内部错误",
"schema": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.ErrorResponse"
2026-04-13 16:16:39 +08:00
}
}
}
}
}
},
"definitions": {
2026-04-15 15:19:39 +08:00
"model.CreateEdgeRequest": {
2026-04-15 14:24:39 +08:00
"type": "object",
"required": [
"id",
"label",
"source",
"target"
],
"properties": {
"id": {
"type": "string",
"example": "edge_123"
},
"label": {
"type": "string",
"example": "包含"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"source": {
"type": "string",
"example": "node_1"
},
"target": {
"type": "string",
"example": "node_2"
},
"type": {
"type": "string",
"example": "CONTAINS"
}
}
},
2026-04-15 15:19:39 +08:00
"model.CreateNodeRequest": {
2026-04-15 14:24:39 +08:00
"type": "object",
"required": [
"id",
"label",
"type"
],
"properties": {
"id": {
"type": "string",
"example": "node_123"
},
"label": {
"type": "string",
"example": "人工智能"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"type": {
"type": "string",
"example": "概念"
},
"x": {
"type": "number",
"example": 100
},
"y": {
"type": "number",
"example": 200
}
}
},
2026-04-15 15:19:39 +08:00
"model.DeleteResponse": {
2026-04-15 14:24:39 +08:00
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "node_123"
},
"message": {
"type": "string",
"example": "节点已成功删除"
},
"success": {
"type": "boolean",
"example": true
}
}
},
2026-04-15 15:19:39 +08:00
"model.Edge": {
2026-04-13 16:16:39 +08:00
"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 15:19:39 +08:00
"model.EdgeResponse": {
2026-04-15 14:24:39 +08:00
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "edge_123"
},
"label": {
"type": "string",
"example": "包含"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"source": {
"type": "string",
"example": "node_1"
},
"target": {
"type": "string",
"example": "node_2"
},
"type": {
"type": "string",
"example": "CONTAINS"
}
}
},
2026-04-15 15:19:39 +08:00
"model.ErrorResponse": {
2026-04-13 16:16:39 +08:00
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
2026-04-15 15:19:39 +08:00
"model.GraphData": {
2026-04-13 16:16:39 +08:00
"type": "object",
"properties": {
"edges": {
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Edge"
2026-04-13 16:16:39 +08:00
}
},
"nodes": {
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Node"
2026-04-13 16:16:39 +08:00
}
}
}
},
2026-04-15 15:19:39 +08:00
"model.NeighborResponse": {
2026-04-13 16:16:39 +08:00
"type": "object",
"properties": {
"edges": {
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Edge"
2026-04-13 16:16:39 +08:00
}
},
"nodes": {
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Node"
2026-04-13 16:16:39 +08:00
}
}
}
},
2026-04-15 15:19:39 +08:00
"model.Node": {
2026-04-13 16:16:39 +08:00
"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"
}
}
},
2026-04-15 15:19:39 +08:00
"model.NodeResponse": {
2026-04-13 16:16:39 +08:00
"type": "object",
"properties": {
"id": {
2026-04-15 15:19:39 +08:00
"type": "string"
2026-04-13 16:16:39 +08:00
},
"label": {
2026-04-15 15:19:39 +08:00
"type": "string"
},
"neighbors": {
"type": "array",
"items": {
"$ref": "#/definitions/model.Node"
}
2026-04-13 16:16:39 +08:00
},
"properties": {
"type": "object",
"additionalProperties": true
},
2026-04-15 15:19:39 +08:00
"style": {
"type": "object",
"additionalProperties": true
},
2026-04-13 16:16:39 +08:00
"type": {
2026-04-15 15:19:39 +08:00
"type": "string"
},
"x": {
"type": "number"
},
"y": {
"type": "number"
2026-04-13 16:16:39 +08:00
}
}
},
2026-04-15 15:19:39 +08:00
"model.SearchResponse": {
2026-04-13 16:16:39 +08:00
"type": "object",
"properties": {
"count": {
"type": "integer"
},
2026-04-15 15:19:39 +08:00
"nodes": {
2026-04-13 16:16:39 +08:00
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.Node"
2026-04-13 16:16:39 +08:00
}
2026-04-15 15:19:39 +08:00
},
"query": {
"type": "string"
2026-04-13 16:16:39 +08:00
}
}
2026-04-15 14:24:39 +08:00
},
2026-04-15 15:19:39 +08:00
"model.SimpleEdge": {
2026-04-15 14:52:33 +08:00
"type": "object",
"properties": {
"label": {
"type": "string",
"example": "包含"
},
"source": {
"type": "string",
"example": "1"
},
"target": {
"type": "string",
"example": "2"
},
"type": {
"type": "string",
"example": "CONTAINS"
}
}
},
2026-04-15 15:19:39 +08:00
"model.SimpleGraphData": {
2026-04-15 14:52:33 +08:00
"type": "object",
"properties": {
"edges": {
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.SimpleEdge"
2026-04-15 14:52:33 +08:00
}
},
"nodes": {
"type": "array",
"items": {
2026-04-15 15:19:39 +08:00
"$ref": "#/definitions/model.SimpleNode"
2026-04-15 14:52:33 +08:00
}
}
}
},
2026-04-15 15:19:39 +08:00
"model.SimpleNode": {
2026-04-15 14:52:33 +08:00
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "1"
},
"label": {
"type": "string",
"example": "人工智能"
},
"type": {
"type": "string",
"example": "概念"
}
}
},
2026-04-15 15:19:39 +08:00
"model.UpdateNodeRequest": {
2026-04-15 14:24:39 +08:00
"type": "object",
"properties": {
"label": {
"type": "string",
"example": "机器学习"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"type": {
"type": "string",
"example": "工具"
},
"x": {
"type": "number",
"example": 150
},
"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)
}