ListSearchSourceCode - 搜索代码片段数据

更新时间:
复制 MD 格式

根据筛选条件搜索相应的代码片段。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求语法

POST /search/code HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

organizationId

string

是

企业标识,也称企业 id,字符串形式,可在云效访问链接中获取,如 https://devops.aliyun.com/organization/【OrganizationId】

66c0c9fffeb86b450c199fcd

body

object

是

请求 Body

keyword

string

是

搜索关键字

test

page

integer

否

页码 默认值为 1,从第 1 页开始

1

pageSize

integer

否

每页大小 默认值为 20,取值范围【1,100】

20

sort

string

否

排序方式,默认为 desc

  • desc:降序

  • asc:升序

desc

order

string

否

排序字段,默认为 default

  • default:默认排序,即综合排序

  • created_at:创建时间

  • updated_at:更新时间

  • star:收藏数

  • like:点赞数

  • comment:评论数

  • reply:回复数

default

scope

string

否

搜索范围,默认为 all

  • all:全局范围,公开库以及有权限的 private 库

  • mine:只作为库或组成员,并且有读权限

all

repoPath

object

否

代码仓库查询条件

value

string

否

代码库的全路径,例如:organization/group/repo

说明

如果有多个代码库路径,使用英文逗号","隔开

xxx

operatorType

string

否

查询条件类型

  • equal:等于

  • unequal:不等于

  • and:与

  • or:或

  • not:非

equal

matchType

string

否

查询匹配类型

  • term:精确匹配

  • regex:正则匹配

  • phrase:短语匹配,默认方式

  • wildcard:模糊匹配

term

filePath

object

否

代码文件路径,支持正则表达式

value

string

否

文件的全路径,例如:organization/group/repo/file

说明

如多个文件全路径,使用英文逗号","隔开

orgId/test-group/spring-boot-demo/test.java

operatorType

string

否

查询条件类型

  • equal:等于

  • unequal:不等于

  • and:与

  • or:或

  • not:非

equal

matchType

string

否

查询匹配类型

  • term:精确匹配

  • regex:正则匹配

  • phrase:短语匹配,默认方式

  • wildcard:模糊匹配

term

language

string

否

编程语言

Java

isCodeBlock

boolean

否

是否查询代码方法块数据,如类、方法等

false

返回参数

名称

类型

描述

示例值

object

Schema of Response

requestId

string

请求 ID

ASSDS-ASSASX-XSAXSA-XSAXSAXS

errorMessage

string

错误信息

""

errorCode

string

错误码

SYSTEM_UNKNOWN_ERROR

success

boolean

调用是否成功

true

total

integer

总记录数

2

result

array<object>

返回结果列表

array<object>

返回结果

docId

string

文档 ID

60d54f3daccf2bbd6659f3ad/gitlabhq/master/spec/frontend/snippets/test_utils.js

highlightTextMap

object

高亮文本信息

organizationId

string

高亮企业 ID

60de7a6852743a5162b5f957

fileName

string

命中的文件名

test.java

clob

string

命中的文件内容中的某个片段

xxx

language

string

编程语言

java

source

object

ES 返回的源信息

repoPath

string

代码库完整路径(含完整组路径)

codeup/test-repo

fileName

string

文件名称

test_utils.js

filePath

string

文件路径

spec/frontend/snippets/test_utils.js

language

string

编程语言

JavaScript

checkinDate

string

最近一次 commit 时间

2022-10-10 10:00:00

branch

string

分支名称

master

organizationId

string

企业标识,也称企业 id,字符串形式,可在云效访问链接中获取,如 https://devops.aliyun.com/organization/【OrganizationId】

60de7a6852743a5162b5f957

示例

正常返回示例

JSON格式

{
  "requestId": "ASSDS-ASSASX-XSAXSA-XSAXSAXS",
  "errorMessage": "\"\"",
  "errorCode": "\t\nSYSTEM_UNKNOWN_ERROR",
  "success": true,
  "total": 2,
  "result": [
    {
      "docId": "60d54f3daccf2bbd6659f3ad/gitlabhq/master/spec/frontend/snippets/test_utils.js",
      "highlightTextMap": {
        "organizationId": "60de7a6852743a5162b5f957",
        "fileName": "test.java",
        "clob": "xxx",
        "language": "java"
      },
      "source": {
        "repoPath": "codeup/test-repo",
        "fileName": "test_utils.js",
        "filePath": "spec/frontend/snippets/test_utils.js",
        "language": "JavaScript",
        "checkinDate": "2022-10-10 10:00:00",
        "branch": "master",
        "organizationId": "60de7a6852743a5162b5f957"
      }
    }
  ]
}

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。