已关闭
feat(discussions): 支持 获取项目讨论评论列表 API #469
aflyingto创建于  7月13日关闭于  8月8日
aflyingto成员
7月13日 创建

背景

GitCode API 文档已提供 Discussions 页面相关 API,但 gitcode-cli 当前尚未适配。该 Issue 用于跟踪 CLI 对此接口的需求、设计与实现。

API 摘要

  • 标题: 获取项目讨论评论列表
  • Method: GET
  • Path: /api/v5/repos/{owner}/{repo}/discuss/{number}/comment
  • Operation ID: get_api_v5_repos_{owner}_{repo}_discuss_{number}_comment
  • Tags: Repositories, Repositories
  • Deprecated: false
  • Description: 无

Request Parameters

Name In Required Type Description
owner path yes string 仓库所属空间地址(企业、组织或个人的地址path)
repo path yes string 仓库路径(path)
number path yes string
access_token query no string 用户授权码
page query no string 当前的页码
per_page query no string 每页的数量,最大为 100,默认 20
order query no string 排序,按创建时间升序(time_asc);按创建时间降序(time_desc),按热度值降序(hot_desc)

Request Body

无。

Responses

200

  • Description: 成功响应
  • Headers: 无
  • Content-Types: application/json

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"
      }
    }
  }
}

原始 OpenAPI Operation

{
  "deprecated": false,
  "description": "",
  "operationId": "get_api_v5_repos_{owner}_{repo}_discuss_{number}_comment",
  "tags": [
    "Repositories",
    "Repositories"
  ],
  "parameters": [
    {
      "name": "owner",
      "in": "path",
      "description": "仓库所属空间地址(企业、组织或个人的地址path)",
      "required": true,
      "example": "",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "repo",
      "in": "path",
      "description": "仓库路径(path)",
      "required": true,
      "example": "",
      "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,
      "example": "",
      "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/repos/{owner}/{repo}/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",
        "repos",
        ":owner",
        ":repo",
        "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": "owner"
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) 仓库路径(path)",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "repo"
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) ",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "number"
        }
      ]
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET"
  }
}

初步验收建议

  • 增加对应 API client/query 方法。
  • 建议设计项目级 discussion 读取命令,并支持 -R owner/repo。
  • 设计 agent-friendly 的 CLI 命令、帮助文本、JSON 输出和错误处理。
  • 单元测试覆盖参数映射、响应解析和错误路径。
  • 如做真实命令验证,只能使用 infra-test/* 仓库。
  • 不暴露或打印 token;文档中的 access_token 仅作为 API 参数记录,CLI 优先复用现有认证机制。
likedislike
Aaflyingto成员
7月13日 添加了label:risk/mediumscope/apiscope/discussions, status/triage,type/feature
Aaflyingto成员
7月13日 关联了里程碑:Discussions M1: 页面只读 API 适配
aflyingto成员
8月8日 评论:

验证记录见 #465 评论(gc-api-doc 确认 4 端点 + 评论/回复 schema 一致)。同片交付。

likedislike
Aaflyingto成员
8月8日 添加了label:status/in-progress, status/verified
Aaflyingto成员
8月8日 关联了pull request:feat(discussions): discussion comments + replies (org+project) (#465,#466,#469,#470)
Aaflyingto成员
8月8日 关闭了 issue