Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 399cbc9

Browse files
update api docs for contents (#5985) (#13)
Include example to describe api response for the contents api endpoint when no path is specified in the request.
1 parent eafd054 commit 399cbc9

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

‎Repositories/Contents.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Content-Type: application/octet-stream
6969
## Get contents
7070

7171
```
72-
GET /repos/:username/:reponame/contents/:ref/:path
72+
GET /repos/:username/:reponame/contents/:path
7373
```
7474

7575
### Parameters
@@ -78,6 +78,36 @@ GET /repos/:username/:reponame/contents/:ref/:path
7878
|----|----|-----------|
7979
|`ref`|`string`|The name of the commit/branch/tag. The default is the default branch of the repository, usually is `master`.|
8080

81+
### Response if path is empty
82+
83+
It's possible for `:path` to be empty. If no path is specified the contents at the root of the repository are returned.
84+
85+
```
86+
Status: 200 OK
87+
```
88+
```json
89+
[
90+
{
91+
"type": "file",
92+
"encoding": "base64",
93+
"size": 50,
94+
"name": "Sum.groovy",
95+
"path": "src/Sum.groovy",
96+
"content": "c3RhdGljIGludCBzdW0oaW50IHZhbDEsIHZhbDIpIHsKICAgIHZhbDEgKyB2YWwyCn0=",
97+
"sha": "9f221918607d78c1db3f6c6d5afa68a66b1146a8",
98+
"url": "https://try.gogs.io/api/v1/repos/unknwon/git-module-testrepo/contents/src/Sum.groovy",
99+
"git_url": "https://try.gogs.io/api/v1/repos/unknwon/git-module-testrepo/git/blobs/9f221918607d78c1db3f6c6d5afa68a66b1146a8",
100+
"html_url": "https://try.gogs.io/unknwon/git-module-testrepo/src/master/Sum.groovy",
101+
"download_url": "https://try.gogs.io/unknwon/git-module-testrepo/raw/master/Sum.groovy",
102+
"_links": {
103+
"git": "https://try.gogs.io/api/v1/repos/unknwon/git-module-testrepo/git/blobs/9f221918607d78c1db3f6c6d5afa68a66b1146a8",
104+
"self": "https://try.gogs.io/api/v1/repos/unknwon/git-module-testrepo/contents/src/Sum.groovy",
105+
"html": "https://try.gogs.io/unknwon/git-module-testrepo/src/master/Sum.groovy"
106+
}
107+
}
108+
]
109+
```
110+
81111
### Response if content is a file
82112
```
83113
Status: 200 OK

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /