Skip to content

Page parameter for repo search API #2915

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 1 commit into from
Nov 15, 2017
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
12 changes: 9 additions & 3 deletions public/swagger.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,19 @@
},
{
"type": "integer",
"description": "if provided, will return only repos owned by the user with the given id",
"description": "search only for repos that the user with the given id owns or contributes to",
"name": "uid",
"in": "query"
},
{
"type": "integer",
"description": "maximum number of repos to return",
"description": "page number of results to return (1-based)",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "page size of results, maximum page size is 50",
"name": "limit",
"in": "query"
},
Expand All @@ -867,7 +873,7 @@
},
{
"type": "boolean",
"description": "only search for repositories owned by the authenticated user",
"description": "if `uid` is given, search only for repos that the user owns",
"name": "exclusive",
"in": "query"
}
Expand Down
11 changes: 8 additions & 3 deletions routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ func Search(ctx *context.APIContext) {
// type: string
// - name: uid
// in: query
// description: if provided, will return only repos owned by the user with the given id
// description: search only for repos that the user with the given id owns or contributes to
// type: integer
// - name: page
// in: query
// description: page number of results to return (1-based)
// type: integer
// - name: limit
// in: query
// description: maximum number of repos to return
// description: page size of results, maximum page size is 50
// type: integer
// - name: mode
// in: query
Expand All @@ -47,7 +51,7 @@ func Search(ctx *context.APIContext) {
// type: string
// - name: exclusive
// in: query
// description: only search for repositories owned by the authenticated user
// description: if `uid` is given, search only for repos that the user owns
// type: boolean
// responses:
// "200":
Expand All @@ -57,6 +61,7 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{
Keyword: strings.Trim(ctx.Query("q"), " "),
OwnerID: ctx.QueryInt64("uid"),
Page: ctx.QueryInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
Collaborate: util.OptionalBoolNone,
}
Expand Down