Skip to content

Commit 96d4128

Browse files
authored
[API] GetCombinedCommitStatusByRef always return json & swagger doc fixes (#14047)
* Fix swagger docs * always return json
1 parent df11075 commit 96d4128

File tree

3 files changed

+136
-5
lines changed

3 files changed

+136
-5
lines changed

routers/api/v1/repo/status.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ type combinedCommitStatus struct {
244244

245245
// GetCombinedCommitStatusByRef returns the combined status for any given commit hash
246246
func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
247-
// swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoGetCombinedStatusByRef
247+
// swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/status repository repoGetCombinedStatusByRef
248248
// ---
249249
// summary: Get a commit's combined status, by branch/tag/commit reference
250250
// produces:
@@ -272,7 +272,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
272272
// required: false
273273
// responses:
274274
// "200":
275-
// "$ref": "#/responses/Status"
275+
// "$ref": "#/responses/CombinedStatus"
276276
// "400":
277277
// "$ref": "#/responses/error"
278278

@@ -292,7 +292,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
292292
}
293293

294294
if len(statuses) == 0 {
295-
ctx.Status(http.StatusOK)
295+
ctx.JSON(http.StatusOK, &api.CombinedStatus{})
296296
return
297297
}
298298

routers/api/v1/swagger/repo.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,10 @@ type swaggerLanguageStatistics struct {
309309
// in: body
310310
Body map[string]int64 `json:"body"`
311311
}
312+
313+
// CombinedStatus
314+
// swagger:response CombinedStatus
315+
type swaggerCombinedStatus struct {
316+
// in: body
317+
Body api.CombinedStatus `json:"body"`
318+
}

templates/swagger/v1_json.tmpl

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,7 @@
28292829
}
28302830
}
28312831
},
2832-
"/repos/{owner}/{repo}/commits/{ref}/statuses": {
2832+
"/repos/{owner}/{repo}/commits/{ref}/status": {
28332833
"get": {
28342834
"produces": [
28352835
"application/json"
@@ -2870,7 +2870,88 @@
28702870
],
28712871
"responses": {
28722872
"200": {
2873-
"$ref": "#/responses/Status"
2873+
"$ref": "#/responses/CombinedStatus"
2874+
},
2875+
"400": {
2876+
"$ref": "#/responses/error"
2877+
}
2878+
}
2879+
}
2880+
},
2881+
"/repos/{owner}/{repo}/commits/{ref}/statuses": {
2882+
"get": {
2883+
"produces": [
2884+
"application/json"
2885+
],
2886+
"tags": [
2887+
"repository"
2888+
],
2889+
"summary": "Get a commit's statuses, by branch/tag/commit reference",
2890+
"operationId": "repoListStatusesByRef",
2891+
"parameters": [
2892+
{
2893+
"type": "string",
2894+
"description": "owner of the repo",
2895+
"name": "owner",
2896+
"in": "path",
2897+
"required": true
2898+
},
2899+
{
2900+
"type": "string",
2901+
"description": "name of the repo",
2902+
"name": "repo",
2903+
"in": "path",
2904+
"required": true
2905+
},
2906+
{
2907+
"type": "string",
2908+
"description": "name of branch/tag/commit",
2909+
"name": "ref",
2910+
"in": "path",
2911+
"required": true
2912+
},
2913+
{
2914+
"enum": [
2915+
"oldest",
2916+
"recentupdate",
2917+
"leastupdate",
2918+
"leastindex",
2919+
"highestindex"
2920+
],
2921+
"type": "string",
2922+
"description": "type of sort",
2923+
"name": "sort",
2924+
"in": "query"
2925+
},
2926+
{
2927+
"enum": [
2928+
"pending",
2929+
"success",
2930+
"error",
2931+
"failure",
2932+
"warning"
2933+
],
2934+
"type": "string",
2935+
"description": "type of state",
2936+
"name": "state",
2937+
"in": "query"
2938+
},
2939+
{
2940+
"type": "integer",
2941+
"description": "page number of results to return (1-based)",
2942+
"name": "page",
2943+
"in": "query"
2944+
},
2945+
{
2946+
"type": "integer",
2947+
"description": "page size of results",
2948+
"name": "limit",
2949+
"in": "query"
2950+
}
2951+
],
2952+
"responses": {
2953+
"200": {
2954+
"$ref": "#/responses/StatusList"
28742955
},
28752956
"400": {
28762957
"$ref": "#/responses/error"
@@ -11240,6 +11321,43 @@
1124011321
},
1124111322
"x-go-package": "code.gitea.io/gitea/modules/structs"
1124211323
},
11324+
"CombinedStatus": {
11325+
"description": "CombinedStatus holds the combined state of several statuses for a single commit",
11326+
"type": "object",
11327+
"properties": {
11328+
"commit_url": {
11329+
"type": "string",
11330+
"x-go-name": "CommitURL"
11331+
},
11332+
"repository": {
11333+
"$ref": "#/definitions/Repository"
11334+
},
11335+
"sha": {
11336+
"type": "string",
11337+
"x-go-name": "SHA"
11338+
},
11339+
"state": {
11340+
"$ref": "#/definitions/StatusState"
11341+
},
11342+
"statuses": {
11343+
"type": "array",
11344+
"items": {
11345+
"$ref": "#/definitions/Status"
11346+
},
11347+
"x-go-name": "Statuses"
11348+
},
11349+
"total_count": {
11350+
"type": "integer",
11351+
"format": "int64",
11352+
"x-go-name": "TotalCount"
11353+
},
11354+
"url": {
11355+
"type": "string",
11356+
"x-go-name": "URL"
11357+
}
11358+
},
11359+
"x-go-package": "code.gitea.io/gitea/modules/structs"
11360+
},
1124311361
"Comment": {
1124411362
"description": "Comment represents a comment on a commit or issue",
1124511363
"type": "object",
@@ -15532,6 +15650,12 @@
1553215650
}
1553315651
}
1553415652
},
15653+
"CombinedStatus": {
15654+
"description": "CombinedStatus",
15655+
"schema": {
15656+
"$ref": "#/definitions/CombinedStatus"
15657+
}
15658+
},
1553515659
"Comment": {
1553615660
"description": "Comment",
1553715661
"schema": {

0 commit comments

Comments
 (0)