basePath: / definitions: model.CreateEdgeRequest: properties: id: example: edge_123 type: string label: example: 包含 type: string properties: additionalProperties: true type: object source: example: node_1 type: string target: example: node_2 type: string type: example: CONTAINS type: string required: - id - label - source - target type: object model.CreateNodeRequest: properties: id: example: node_123 type: string label: example: 人工智能 type: string properties: additionalProperties: true type: object type: example: 概念 type: string x: example: 100 type: number "y": example: 200 type: number required: - id - label - type type: object model.DeleteResponse: properties: id: example: node_123 type: string message: example: 节点已成功删除 type: string success: example: true type: boolean type: object model.Edge: properties: id: type: string label: type: string properties: additionalProperties: true type: object source: type: string style: additionalProperties: true type: object target: type: string type: type: string type: object model.EdgeResponse: properties: id: example: edge_123 type: string label: example: 包含 type: string properties: additionalProperties: true type: object source: example: node_1 type: string target: example: node_2 type: string type: example: CONTAINS type: string type: object model.ErrorResponse: properties: error: type: string message: type: string type: object model.GraphData: properties: edges: items: $ref: '#/definitions/model.Edge' type: array nodes: items: $ref: '#/definitions/model.Node' type: array type: object model.NeighborResponse: properties: edges: items: $ref: '#/definitions/model.Edge' type: array nodes: items: $ref: '#/definitions/model.Node' type: array type: object model.Node: properties: id: type: string label: type: string properties: additionalProperties: true type: object style: additionalProperties: true type: object type: type: string x: type: number "y": type: number type: object model.NodeResponse: properties: id: type: string label: type: string neighbors: items: $ref: '#/definitions/model.Node' type: array properties: additionalProperties: true type: object style: additionalProperties: true type: object type: type: string x: type: number "y": type: number type: object model.SearchResponse: properties: count: type: integer nodes: items: $ref: '#/definitions/model.Node' type: array query: type: string type: object model.SimpleEdge: properties: label: example: 包含 type: string source: example: "1" type: string target: example: "2" type: string type: example: CONTAINS type: string type: object model.SimpleGraphData: properties: edges: items: $ref: '#/definitions/model.SimpleEdge' type: array nodes: items: $ref: '#/definitions/model.SimpleNode' type: array type: object model.SimpleNode: properties: id: example: "1" type: string label: example: 人工智能 type: string type: example: 概念 type: string type: object model.UpdateNodeRequest: properties: label: example: 机器学习 type: string properties: additionalProperties: true type: object type: example: 工具 type: string x: example: 150 type: number "y": example: 250 type: number type: object host: localhost:3001 info: contact: {} description: 知识图谱后端服务,提供图数据查询、节点搜索等功能 title: 知识图谱 API version: 1.0.0 paths: /api/edges: post: consumes: - application/json description: 在知识图谱中创建一个新边(关系) parameters: - description: 边创建请求 in: body name: request required: true schema: $ref: '#/definitions/model.CreateEdgeRequest' produces: - application/json responses: "200": description: 创建成功 schema: $ref: '#/definitions/model.EdgeResponse' "400": description: 请求错误 schema: $ref: '#/definitions/model.ErrorResponse' "404": description: 源节点或目标节点未找到 schema: $ref: '#/definitions/model.ErrorResponse' "409": description: 边已存在 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 创建边 /api/edges/{id}: delete: description: 从知识图谱中删除指定的边 parameters: - description: 边ID in: path name: id required: true type: string produces: - application/json responses: "200": description: 删除成功 schema: $ref: '#/definitions/model.DeleteResponse' "404": description: 边未找到 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 删除边 /api/graph: get: description: 获取知识图谱的全部节点和边数据 produces: - application/json responses: "200": description: 成功 schema: $ref: '#/definitions/model.GraphData' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 获取图数据 /api/graph/simpleJson: get: description: 获取知识图谱的全部节点和边数据(仅保留核心信息,适合LLM处理) produces: - application/json responses: "200": description: 成功 schema: $ref: '#/definitions/model.SimpleGraphData' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 获取简化图数据 /api/graph/stats: get: description: 获取知识图谱的节点数、边数等统计信息 produces: - application/json responses: "200": description: 成功 schema: additionalProperties: true type: object "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 获取图统计信息 /api/nodes: post: consumes: - application/json description: 在知识图谱中创建一个新节点 parameters: - description: 节点创建请求 in: body name: request required: true schema: $ref: '#/definitions/model.CreateNodeRequest' produces: - application/json responses: "200": description: 创建成功 schema: $ref: '#/definitions/model.Node' "400": description: 请求错误 schema: $ref: '#/definitions/model.ErrorResponse' "409": description: 节点已存在 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 创建节点 /api/nodes/{id}: delete: description: 从知识图谱中删除指定节点及其相关的所有边 parameters: - description: 节点ID in: path name: id required: true type: string produces: - application/json responses: "200": description: 删除成功 schema: $ref: '#/definitions/model.DeleteResponse' "404": description: 节点未找到 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 删除节点 get: description: 根据节点 ID 获取知识图谱中的节点详细信息 parameters: - description: 节点 ID in: path name: id required: true type: string produces: - application/json responses: "200": description: 成功 schema: $ref: '#/definitions/model.NodeResponse' "400": description: 请求错误 schema: $ref: '#/definitions/model.ErrorResponse' "404": description: 节点未找到 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 获取节点详情 put: consumes: - application/json description: 更新知识图谱中指定节点的信息 parameters: - description: 节点ID in: path name: id required: true type: string - description: 节点更新请求 in: body name: request required: true schema: $ref: '#/definitions/model.UpdateNodeRequest' produces: - application/json responses: "200": description: 更新成功 schema: $ref: '#/definitions/model.Node' "400": description: 请求错误 schema: $ref: '#/definitions/model.ErrorResponse' "404": description: 节点未找到 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 更新节点 /api/nodes/{id}/neighbors: get: description: 根据节点 ID 获取其所有邻居节点及关联边 parameters: - description: 节点 ID in: path name: id required: true type: string produces: - application/json responses: "200": description: 成功 schema: $ref: '#/definitions/model.NeighborResponse' "400": description: 请求错误 schema: $ref: '#/definitions/model.ErrorResponse' "404": description: 节点未找到 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 获取节点邻居 /api/search: get: description: 根据关键词搜索知识图谱中的节点 parameters: - description: 搜索关键词 in: query name: q required: true type: string produces: - application/json responses: "200": description: 成功 schema: $ref: '#/definitions/model.SearchResponse' "400": description: 请求错误 schema: $ref: '#/definitions/model.ErrorResponse' "500": description: 内部错误 schema: $ref: '#/definitions/model.ErrorResponse' summary: 搜索节点 swagger: "2.0"