aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/pull.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/repo/pull.go')
-rw-r--r--routers/api/v1/repo/pull.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index e2e6c2799b..1abc2806f8 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/notification"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
+ "code.gitea.io/gitea/routers/api/v1/utils"
issue_service "code.gitea.io/gitea/services/issue"
pull_service "code.gitea.io/gitea/services/pull"
)
@@ -41,10 +42,6 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
// description: name of the repo
// type: string
// required: true
- // - name: page
- // in: query
- // description: Page number
- // type: integer
// - name: state
// in: query
// description: "State of pull request: open or closed (optional)"
@@ -68,12 +65,22 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
// items:
// type: integer
// format: int64
+ // - name: page
+ // in: query
+ // description: page number of results to return (1-based)
+ // type: integer
+ // - name: limit
+ // in: query
+ // description: page size of results, maximum page size is 50
+ // type: integer
// responses:
// "200":
// "$ref": "#/responses/PullRequestList"
+ listOptions := utils.GetListOptions(ctx)
+
prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{
- Page: ctx.QueryInt("page"),
+ ListOptions: listOptions,
State: ctx.QueryTrim("state"),
SortType: ctx.QueryTrim("sort"),
Labels: ctx.QueryStrings("labels"),
@@ -106,7 +113,7 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
apiPrs[i] = convert.ToAPIPullRequest(prs[i])
}
- ctx.SetLinkHeader(int(maxResults), models.ItemsPerPage)
+ ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.JSON(http.StatusOK, &apiPrs)
}