Skip to content

[API] GetCombinedCommitStatusByRef always return json & swagger doc fixes #14047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions routers/api/v1/repo/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ type combinedCommitStatus struct {

// GetCombinedCommitStatusByRef returns the combined status for any given commit hash
func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoGetCombinedStatusByRef
// swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/status repository repoGetCombinedStatusByRef
// ---
// summary: Get a commit's combined status, by branch/tag/commit reference
// produces:
Expand Down Expand Up @@ -272,7 +272,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
// required: false
// responses:
// "200":
// "$ref": "#/responses/Status"
// "$ref": "#/responses/CombinedStatus"
// "400":
// "$ref": "#/responses/error"

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

if len(statuses) == 0 {
ctx.Status(http.StatusOK)
ctx.JSON(http.StatusOK, &api.CombinedStatus{})
return
}

Expand Down
7 changes: 7 additions & 0 deletions routers/api/v1/swagger/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,10 @@ type swaggerLanguageStatistics struct {
// in: body
Body map[string]int64 `json:"body"`
}

// CombinedStatus
// swagger:response CombinedStatus
type swaggerCombinedStatus struct {
// in: body
Body api.CombinedStatus `json:"body"`
}
128 changes: 126 additions & 2 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2829,7 +2829,7 @@
}
}
},
"/repos/{owner}/{repo}/commits/{ref}/statuses": {
"/repos/{owner}/{repo}/commits/{ref}/status": {
"get": {
"produces": [
"application/json"
Expand Down Expand Up @@ -2870,7 +2870,88 @@
],
"responses": {
"200": {
"$ref": "#/responses/Status"
"$ref": "#/responses/CombinedStatus"
},
"400": {
"$ref": "#/responses/error"
}
}
}
},
"/repos/{owner}/{repo}/commits/{ref}/statuses": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Get a commit's statuses, by branch/tag/commit reference",
"operationId": "repoListStatusesByRef",
"parameters": [
{
"type": "string",
"description": "owner of the repo",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of branch/tag/commit",
"name": "ref",
"in": "path",
"required": true
},
{
"enum": [
"oldest",
"recentupdate",
"leastupdate",
"leastindex",
"highestindex"
],
"type": "string",
"description": "type of sort",
"name": "sort",
"in": "query"
},
{
"enum": [
"pending",
"success",
"error",
"failure",
"warning"
],
"type": "string",
"description": "type of state",
"name": "state",
"in": "query"
},
{
"type": "integer",
"description": "page number of results to return (1-based)",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "page size of results",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/StatusList"
},
"400": {
"$ref": "#/responses/error"
Expand Down Expand Up @@ -11240,6 +11321,43 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"CombinedStatus": {
"description": "CombinedStatus holds the combined state of several statuses for a single commit",
"type": "object",
"properties": {
"commit_url": {
"type": "string",
"x-go-name": "CommitURL"
},
"repository": {
"$ref": "#/definitions/Repository"
},
"sha": {
"type": "string",
"x-go-name": "SHA"
},
"state": {
"$ref": "#/definitions/StatusState"
},
"statuses": {
"type": "array",
"items": {
"$ref": "#/definitions/Status"
},
"x-go-name": "Statuses"
},
"total_count": {
"type": "integer",
"format": "int64",
"x-go-name": "TotalCount"
},
"url": {
"type": "string",
"x-go-name": "URL"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"Comment": {
"description": "Comment represents a comment on a commit or issue",
"type": "object",
Expand Down Expand Up @@ -15532,6 +15650,12 @@
}
}
},
"CombinedStatus": {
"description": "CombinedStatus",
"schema": {
"$ref": "#/definitions/CombinedStatus"
}
},
"Comment": {
"description": "Comment",
"schema": {
Expand Down