Skip to content

Commit 9a137fa

Browse files
kolaentetechknowlogick
authored andcommitted
Added docs for the tree api (#5834)
* Added docs for the tree api * Added missing response definition * Fixed swagger docs
1 parent 62da3be commit 9a137fa

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
@@ -1701,6 +1701,46 @@
17011701
}
17021702
}
17031703
},
1704+
"/repos/{owner}/{repo}/git/trees/{sha}": {
1705+
"get": {
1706+
"produces": [
1707+
"application/json"
1708+
],
1709+
"tags": [
1710+
"repository"
1711+
],
1712+
"summary": "Gets the tree of a repository.",
1713+
"operationId": "GetTree",
1714+
"parameters": [
1715+
{
1716+
"type": "string",
1717+
"description": "owner of the repo",
1718+
"name": "owner",
1719+
"in": "path",
1720+
"required": true
1721+
},
1722+
{
1723+
"type": "string",
1724+
"description": "name of the repo",
1725+
"name": "repo",
1726+
"in": "path",
1727+
"required": true
1728+
},
1729+
{
1730+
"type": "string",
1731+
"description": "sha of the commit",
1732+
"name": "sha",
1733+
"in": "path",
1734+
"required": true
1735+
}
1736+
],
1737+
"responses": {
1738+
"200": {
1739+
"$ref": "#/responses/GitTreeResponse"
1740+
}
1741+
}
1742+
}
1743+
},
17041744
"/repos/{owner}/{repo}/hooks": {
17051745
"get": {
17061746
"produces": [
@@ -7127,6 +7167,38 @@
71277167
},
71287168
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
71297169
},
7170+
"GitEntry": {
7171+
"description": "GitEntry represents a git tree",
7172+
"type": "object",
7173+
"properties": {
7174+
"mode": {
7175+
"type": "string",
7176+
"x-go-name": "Mode"
7177+
},
7178+
"path": {
7179+
"type": "string",
7180+
"x-go-name": "Path"
7181+
},
7182+
"sha": {
7183+
"type": "string",
7184+
"x-go-name": "SHA"
7185+
},
7186+
"size": {
7187+
"type": "integer",
7188+
"format": "int64",
7189+
"x-go-name": "Size"
7190+
},
7191+
"type": {
7192+
"type": "string",
7193+
"x-go-name": "Type"
7194+
},
7195+
"url": {
7196+
"type": "string",
7197+
"x-go-name": "URL"
7198+
}
7199+
},
7200+
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
7201+
},
71307202
"GitObject": {
71317203
"type": "object",
71327204
"title": "GitObject represents a Git object.",
@@ -7146,6 +7218,32 @@
71467218
},
71477219
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
71487220
},
7221+
"GitTreeResponse": {
7222+
"description": "GitTreeResponse returns a git tree",
7223+
"type": "object",
7224+
"properties": {
7225+
"sha": {
7226+
"type": "string",
7227+
"x-go-name": "SHA"
7228+
},
7229+
"tree": {
7230+
"type": "array",
7231+
"items": {
7232+
"$ref": "#/definitions/GitEntry"
7233+
},
7234+
"x-go-name": "Entries"
7235+
},
7236+
"truncated": {
7237+
"type": "boolean",
7238+
"x-go-name": "Truncated"
7239+
},
7240+
"url": {
7241+
"type": "string",
7242+
"x-go-name": "URL"
7243+
}
7244+
},
7245+
"x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
7246+
},
71497247
"Issue": {
71507248
"description": "Issue represents an issue in a repository",
71517249
"type": "object",
@@ -8290,6 +8388,12 @@
82908388
}
82918389
}
82928390
},
8391+
"GitTreeResponse": {
8392+
"description": "GitTreeResponse",
8393+
"schema": {
8394+
"$ref": "#/definitions/GitTreeResponse"
8395+
}
8396+
},
82938397
"Hook": {
82948398
"description": "Hook",
82958399
"schema": {

0 commit comments

Comments
 (0)