已关闭
feat(discussions): 支持 获取组织讨论评论列表 API #465
aflyingto创建于 7月13日关闭于 8月8日
aflyingto
8月8日 评论:
8月8日 评论:
验证记录(#465/#466/#469/#470 讨论评论 + 回复)
- 当前验证分支:
main(HEAD7cfee80) - 验证方式:按 §9/§5.9.B 查
gc-api-doc确认 4 端点;CLI 当前 discussions 仅有 list/view(#463/#464/#467/#468 已合入),无 comments/replies 命令
gc-api-doc 确认的端点
| issue | method | path | params |
|---|---|---|---|
| #465 org 评论 | GET | /api/v5/orgs/{org}/discuss/{number}/comment |
page, per_page, order(time_asc/time_desc/hot_desc) |
| #466 org 回复 | GET | /api/v5/orgs/{org}/discuss/{number}/comment/{comment_id}/reply |
page, per_page |
| #469 项目评论 | GET | /api/v5/repos/{owner}/{repo}/discuss/{number}/comment |
page, per_page, order |
| #470 项目回复 | GET | /api/v5/repos/{owner}/{repo}/discuss/{number}/comment/{comment_id}/reply |
page, per_page |
- response 200:均为 array;评论与回复 schema 完全一致
- 字段:id(string), created_at(string), author(object, 同讨论 author), content(string), md_content(string), is_hide(int), reply_total(int), like_total(int), is_like(bool), is_deleted(int), is_remark(int)
- 项目端点 schema 与组织一致(仅 path 不同)→ 复用
DiscussionComment结构
实现方案
api/queries_discussions.go:新增DiscussionComment结构 + 4 个 api 函数(ListOrg/RepoDiscussionComments + ListOrg/RepoDiscussionCommentReplies,复用 opts)pkg/cmd/discussions/comments/:comments 子命令组(org scope:list/replies,--org)+ 共享 PrintCommentspkg/cmd/discussions/project/comments/:project comments 子命令组(list/replies,-R,复用 PrintComments)- 注册 + 单测 + infra-test/gitcode-cli 实测 + docs


背景
GitCode API 文档已提供 Discussions 页面相关 API,但 gitcode-cli 当前尚未适配。该 Issue 用于跟踪 CLI 对此接口的需求、设计与实现。
API 摘要
GET/api/v5/orgs/{org}/discuss/{number}/commentget_api_v5_orgs_{org}_discuss_{number}_commentOrganizations,RepositoriesfalseRequest Parameters
orgnumberaccess_tokenpageper_pageorderRequest Body
无。
Responses
200
application/jsonapplication/json schema
{ "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "created_at": { "type": "string" }, "author": { "type": "object", "properties": { "avatar_url": { "type": "string" }, "id": { "type": "string" }, "object_id": { "type": "string" }, "login": { "type": "string" }, "name": { "type": "string" } }, "required": [ "avatar_url", "id", "object_id", "login", "name" ] }, "content": { "type": "string" }, "md_content": { "type": "string" }, "is_hide": { "type": "integer" }, "reply_total": { "type": "integer" }, "like_total": { "type": "integer" }, "is_like": { "type": "boolean" }, "is_deleted": { "type": "integer" }, "is_remark": { "type": "integer" } } } }原始 OpenAPI Operation
{ "deprecated": false, "description": "", "operationId": "get_api_v5_orgs_{org}_discuss_{number}_comment", "tags": [ "Organizations", "Repositories" ], "parameters": [ { "name": "org", "in": "path", "description": "组织的path", "required": true, "schema": { "type": "string" } }, { "name": "number", "in": "path", "description": "讨论的编号", "required": true, "schema": { "type": "string" } }, { "name": "access_token", "in": "query", "description": "用户授权码", "required": false, "example": "", "schema": { "type": "string" } }, { "name": "page", "in": "query", "description": "当前的页码", "required": false, "schema": { "type": "string" } }, { "name": "per_page", "in": "query", "description": "每页的数量,最大为 100,默认 20", "required": false, "schema": { "type": "string" } }, { "name": "order", "in": "query", "description": "排序,按创建时间升序(time_asc);按创建时间降序(time_desc),按热度值降序(hot_desc)", "required": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "成功响应", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "created_at": { "type": "string" }, "author": { "type": "object", "properties": { "avatar_url": { "type": "string" }, "id": { "type": "string" }, "object_id": { "type": "string" }, "login": { "type": "string" }, "name": { "type": "string" } }, "required": [ "avatar_url", "id", "object_id", "login", "name" ] }, "content": { "type": "string" }, "md_content": { "type": "string" }, "is_hide": { "type": "integer" }, "reply_total": { "type": "integer" }, "like_total": { "type": "integer" }, "is_like": { "type": "boolean" }, "is_deleted": { "type": "integer" }, "is_remark": { "type": "integer" } } } } } }, "headers": {} } }, "security": [], "method": "get", "path": "/api/v5/orgs/{org}/discuss/{number}/comment", "servers": [ { "url": "https://api.gitcode.com", "description": "正式环境" } ], "securitySchemes": {}, "info": { "title": "GicodeOpenAPI", "description": "", "version": "1.0.0" }, "postman": { "name": "获取组织讨论评论列表", "description": { "content": "", "type": "text/plain" }, "url": { "path": [ "api", "v5", "orgs", ":org", "discuss", ":number", "comment" ], "host": [ "{{baseUrl}}" ], "query": [ { "disabled": false, "description": { "content": "用户授权码", "type": "text/plain" }, "key": "access_token", "value": "" }, { "disabled": false, "description": { "content": "当前的页码", "type": "text/plain" }, "key": "page", "value": "" }, { "disabled": false, "description": { "content": "每页的数量,最大为 100,默认 20", "type": "text/plain" }, "key": "per_page", "value": "" }, { "disabled": false, "description": { "content": "排序,按创建时间升序(time_asc);按创建时间降序(time_desc),按热度值降序(hot_desc)", "type": "text/plain" }, "key": "order", "value": "" } ], "variable": [ { "disabled": false, "description": { "content": "(Required) 组织的path", "type": "text/plain" }, "type": "any", "value": "", "key": "org" }, { "disabled": false, "description": { "content": "(Required) 讨论的编号", "type": "text/plain" }, "type": "any", "value": "", "key": "number" } ] }, "header": [ { "key": "Accept", "value": "application/json" } ], "method": "GET" } }初步验收建议
infra-test/*仓库。access_token仅作为 API 参数记录,CLI 优先复用现有认证机制。