Files
knowledge-graph-agent/backend/docs/swagger.yaml
T

216 lines
5.1 KiB
YAML
Raw Normal View History

2026-04-13 16:16:39 +08:00
basePath: /
definitions:
models.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
models.ErrorResponse:
properties:
error:
type: string
message:
type: string
type: object
models.GraphData:
properties:
edges:
items:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.Edge"
2026-04-13 16:16:39 +08:00
type: array
nodes:
items:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.Node"
2026-04-13 16:16:39 +08:00
type: array
type: object
models.NeighborResponse:
properties:
edges:
items:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.Edge"
2026-04-13 16:16:39 +08:00
type: array
nodes:
items:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.Node"
2026-04-13 16:16:39 +08:00
type: array
type: object
models.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
models.NodeResponse:
properties:
id:
example: "1"
type: string
label:
example: 人工智能
type: string
properties:
additionalProperties: true
type: object
type:
example: 概念
type: string
type: object
models.SearchResponse:
properties:
count:
type: integer
results:
items:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.Node"
2026-04-13 16:16:39 +08:00
type: array
type: object
2026-04-13 16:24:25 +08:00
host: localhost:3001
2026-04-13 16:16:39 +08:00
info:
contact: {}
description: 知识图谱后端服务,提供图数据查询、节点搜索等功能
title: 知识图谱 API
version: 1.0.0
paths:
/api/graph:
get:
description: 获取知识图谱的全部节点和边数据
produces:
2026-04-13 16:24:25 +08:00
- application/json
2026-04-13 16:16:39 +08:00
responses:
"200":
description: 成功
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.GraphData"
2026-04-13 16:16:39 +08:00
"500":
description: 内部错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
summary: 获取图数据
/api/graph/stats:
get:
description: 获取知识图谱的节点数、边数等统计信息
produces:
2026-04-13 16:24:25 +08:00
- application/json
2026-04-13 16:16:39 +08:00
responses:
"200":
description: 成功
schema:
additionalProperties: true
type: object
"500":
description: 内部错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
summary: 获取图统计信息
/api/nodes/{id}:
get:
description: 根据节点 ID 获取知识图谱中的节点详细信息
parameters:
2026-04-13 16:24:25 +08:00
- description: 节点 ID
in: path
name: id
required: true
type: string
2026-04-13 16:16:39 +08:00
produces:
2026-04-13 16:24:25 +08:00
- application/json
2026-04-13 16:16:39 +08:00
responses:
"200":
description: 成功
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.NodeResponse"
2026-04-13 16:16:39 +08:00
"400":
description: 请求错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
"404":
description: 节点未找到
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
"500":
description: 内部错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
summary: 获取节点详情
/api/nodes/{id}/neighbors:
get:
description: 根据节点 ID 获取其所有邻居节点及关联边
parameters:
2026-04-13 16:24:25 +08:00
- description: 节点 ID
in: path
name: id
required: true
type: string
2026-04-13 16:16:39 +08:00
produces:
2026-04-13 16:24:25 +08:00
- application/json
2026-04-13 16:16:39 +08:00
responses:
"200":
description: 成功
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.NeighborResponse"
2026-04-13 16:16:39 +08:00
"400":
description: 请求错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
"404":
description: 节点未找到
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
"500":
description: 内部错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
summary: 获取节点邻居
/api/search:
get:
description: 根据关键词搜索知识图谱中的节点
parameters:
2026-04-13 16:24:25 +08:00
- description: 搜索关键词
in: query
name: q
required: true
type: string
2026-04-13 16:16:39 +08:00
produces:
2026-04-13 16:24:25 +08:00
- application/json
2026-04-13 16:16:39 +08:00
responses:
"200":
description: 成功
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.SearchResponse"
2026-04-13 16:16:39 +08:00
"400":
description: 请求错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
"500":
description: 内部错误
schema:
2026-04-13 16:24:25 +08:00
$ref: "#/definitions/models.ErrorResponse"
2026-04-13 16:16:39 +08:00
summary: 搜索节点
swagger: "2.0"