Skip to content

Commit 8a9f5b3

Browse files
kolaentelafriks
authored andcommitted
Added docs for the tree api (#5835)
* Added docs for the tree api * Updated swagger docs * Added missing response definition * Updated swagger docs * Fixed swagger docs
1 parent f28e174 commit 8a9f5b3

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

routers/api/v1/repo/tree.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ import (
1616

1717
// GetTree get the tree of a repository.
1818
func GetTree(ctx *context.APIContext) {
19+
// swagger:operation GET /repos/{owner}/{repo}/git/trees/{sha} repository GetTree
20+
// ---
21+
// summary: Gets the tree of a repository.
22+
// produces:
23+
// - application/json
24+
// parameters:
25+
// - name: owner
26+
// in: path
27+
// description: owner of the repo
28+
// type: string
29+
// required: true
30+
// - name: repo
31+
// in: path
32+
// description: name of the repo
33+
// type: string
34+
// required: true
35+
// - name: sha
36+
// in: path
37+
// description: sha of the commit
38+
// type: string
39+
// required: true
40+
// responses:
41+
// "200":
42+
// "$ref": "#/responses/GitTreeResponse"
1943
sha := ctx.Params("sha")
2044
if len(sha) == 0 {
2145
ctx.Error(400, "sha not provided", nil)

routers/api/v1/swagger/repo.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,10 @@ type swaggerResponseAttachment struct {
133133
//in: body
134134
Body api.Attachment `json:"body"`
135135
}
136+
137+
// GitTreeResponse
138+
// swagger:response GitTreeResponse
139+
type swaggerGitTreeResponse struct {
140+
//in: body
141+
Body api.GitTreeResponse `json:"body"`
142+
}

templates/swagger/v1_json.tmpl

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,46 @@
16631663
}
16641664
}
16651665
},
1666+
"/repos/{owner}/{repo}/git/trees/{sha}": {
1667+
"get": {
1668+
"produces": [
1669+
"application/json"
1670+
],
1671+
"tags": [
1672+
"repository"
1673+
],
1674+
"summary": "Gets the tree of a repository.",
1675+
"operationId": "GetTree",
1676+
"parameters": [
1677+
{
1678+
"type": "string",
1679+
"description": "owner of the repo",
1680+
"name": "owner",
1681+
"in": "path",
1682+
"required": true
1683+
},
1684+
{
1685+
"type": "string",
1686+
"description": "name of the repo",
1687+
"name": "repo",
1688+
"in": "path",
1689+
"required": true
1690+
},
1691+
{
1692+
"type": "string",
1693+
"description": "sha of the commit",
1694+
"name": "sha",
1695+
"in": "path",
1696+
"required": true
1697+
}
1698+
],
1699+
"responses": {
1700+
"200": {
1701+
"$ref": "#/responses/GitTreeResponse"
1702+
}
1703+
}
1704+
}
1705+
},
16661706
"/repos/{owner}/{repo}/hooks": {
16671707
"get": {
16681708
"produces": [
@@ -7040,6 +7080,38 @@
70407080
},
70417081
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
70427082
},
7083+
"GitEntry": {
7084+
"description": "GitEntry represents a git tree",
7085+
"type": "object",
7086+
"properties": {
7087+
"mode": {
7088+
"type": "string",
7089+
"x-go-name": "Mode"
7090+
},
7091+
"path": {
7092+
"type": "string",
7093+
"x-go-name": "Path"
7094+
},
7095+
"sha": {
7096+
"type": "string",
7097+
"x-go-name": "SHA"
7098+
},
7099+
"size": {
7100+
"type": "integer",
7101+
"format": "int64",
7102+
"x-go-name": "Size"
7103+
},
7104+
"type": {
7105+
"type": "string",
7106+
"x-go-name": "Type"
7107+
},
7108+
"url": {
7109+
"type": "string",
7110+
"x-go-name": "URL"
7111+
}
7112+
},
7113+
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
7114+
},
70437115
"GitObject": {
70447116
"type": "object",
70457117
"title": "GitObject represents a Git object.",
@@ -7059,6 +7131,32 @@
70597131
},
70607132
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
70617133
},
7134+
"GitTreeResponse": {
7135+
"description": "GitTreeResponse returns a git tree",
7136+
"type": "object",
7137+
"properties": {
7138+
"sha": {
7139+
"type": "string",
7140+
"x-go-name": "SHA"
7141+
},
7142+
"tree": {
7143+
"type": "array",
7144+
"items": {
7145+
"$ref": "#/definitions/GitEntry"
7146+
},
7147+
"x-go-name": "Entries"
7148+
},
7149+
"truncated": {
7150+
"type": "boolean",
7151+
"x-go-name": "Truncated"
7152+
},
7153+
"url": {
7154+
"type": "string",
7155+
"x-go-name": "URL"
7156+
}
7157+
},
7158+
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
7159+
},
70627160
"Issue": {
70637161
"description": "Issue represents an issue in a repository",
70647162
"type": "object",
@@ -8200,6 +8298,12 @@
82008298
}
82018299
}
82028300
},
8301+
"GitTreeResponse": {
8302+
"description": "GitTreeResponse",
8303+
"schema": {
8304+
"$ref": "#/definitions/GitTreeResponse"
8305+
}
8306+
},
82038307
"Hook": {
82048308
"description": "Hook",
82058309
"schema": {

0 commit comments

Comments
 (0)