{ "swagger": "2.0", "info": { "title": "CNB OPENAPI", "contact": { "name": "Open API Support", "url": "https://docs.cnb.cool/", "email": "cnb@tencent.com" }, "version": "1.0" }, "paths": { "/{repo}/-/badge/git/{sha}/{badge}": { "get": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Badge" ], "summary": "获取徽章 svg 或 JSON 数据。Get badge svg or JSON data.", "operationId": "GetBadge", "parameters": [ { "type": "string", "description": "仓库完整路径", "name": "repo", "in": "path", "required": true }, { "type": "string", "description": "latest 或 commit 8 位短 hash(例如 89d48c07)", "name": "sha", "in": "path", "required": true }, { "type": "string", "description": "徽章名,例如 pr 事件徽章名为:ci/status/pull_request, 如需获取 JSON 数据,可加上 .json 后缀,如:ci/status/pull_request.json", "name": "badge", "in": "path", "required": true }, { "description": "GetBadge params", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.GetBadgeReq" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.GetBadgeResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-commit-status:r" } }, "/{repo}/-/badge/list": { "get": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Badge" ], "summary": "获取徽章列表数据。List badge data", "operationId": "ListBadge", "parameters": [ { "type": "string", "description": "仓库完整路径", "name": "repo", "in": "path", "required": true }, { "description": "ListBadge params", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.ListBadgeReq" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.ListBadgeResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-commit-status:r" } }, "/{repo}/-/badge/upload": { "post": { "security": [ { "BearerAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/vnd.cnb.api+json" ], "tags": [ "Badge" ], "summary": "上传徽章数据。Upload badge data", "operationId": "UploadBadge", "parameters": [ { "type": "string", "description": "仓库完整路径", "name": "repo", "in": "path", "required": true }, { "description": "UploadBadge params", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.UploadBadgeReq" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.UploadBadgeResult" } } }, "description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-commit-status:rw" } } }, "definitions": { "dto.GetBadgeReq": { "type": "object", "properties": { "branch": { "description": "分支名,例如:main。不传则为默认分支,获取默认分支最新徽章。传了分支名,则获取该分支最新提交记录对应的徽章。", "type": "string" } } }, "dto.GetBadgeResult": { "type": "object", "properties": { "color": { "description": "徽章颜色", "type": "string" }, "label": { "description": "徽章左侧显示内容", "type": "string" }, "link": { "description": "徽章链接", "type": "string" }, "links": { "description": "徽章链接列表", "type": "array", "items": { "type": "string" } }, "message": { "description": "徽章右侧显示内容", "type": "string" } } }, "dto.ListBadgeReq": { "type": "object" }, "dto.ListBadgeResult": { "type": "object", "properties": { "badges": { "description": "徽章列表", "type": "array", "items": { "$ref": "#/definitions/dto.Badge" } } } }, "dto.UploadBadgeReq": { "type": "object", "properties": { "key": { "description": "徽章 key。目前允许上传的 key 包括:security/tca", "type": "string" }, "latest": { "description": "是否上传 latest 徽章。默认为 false:不上传 latest,仅上传 commitid 对应的徽章;true:上传 latest 和 commitid 对应的徽章", "type": "boolean" }, "link": { "description": "点击徽章右侧的跳转链接", "type": "string" }, "message": { "description": "徽章右侧显示内容", "type": "string" }, "sha": { "description": "commit id", "type": "string" }, "value": { "description": "徽章数值,不传默认用 message 代替", "type": "integer" } } }, "dto.UploadBadgeResult": { "type": "object", "properties": { "latest_url": { "description": "latest 对应的徽章 url 地址。如果没有传 latest: true,则该字段为空字符串", "type": "string" }, "url": { "description": "commitid 对应的徽章 url 地址", "type": "string" } } } } }