Skip to content

Commit c03820c

Browse files
Allow to specify if description shall be included in API repo search.
Signed-off-by: David Svantesson <[email protected]>
1 parent 2b9d305 commit c03820c

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

routers/api/v1/repo/repo.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,27 @@ func Search(ctx *context.APIContext) {
9797
// description: sort order, either "asc" (ascending) or "desc" (descending).
9898
// Default is "asc", ignored if "sort" is not specified.
9999
// type: string
100+
// - name: includeDesc
101+
// in: query
102+
// description: include search of keyword within repository description
103+
// type: boolean
100104
// responses:
101105
// "200":
102106
// "$ref": "#/responses/SearchResults"
103107
// "422":
104108
// "$ref": "#/responses/validationError"
105109
opts := &models.SearchRepoOptions{
106-
Keyword: strings.Trim(ctx.Query("q"), " "),
107-
OwnerID: ctx.QueryInt64("uid"),
108-
Page: ctx.QueryInt("page"),
109-
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
110-
TopicOnly: ctx.QueryBool("topic"),
111-
Collaborate: util.OptionalBoolNone,
112-
Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
113-
UserIsAdmin: ctx.IsUserSiteAdmin(),
114-
UserID: ctx.Data["SignedUserID"].(int64),
115-
StarredByID: ctx.QueryInt64("starredBy"),
110+
Keyword: strings.Trim(ctx.Query("q"), " "),
111+
OwnerID: ctx.QueryInt64("uid"),
112+
Page: ctx.QueryInt("page"),
113+
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
114+
TopicOnly: ctx.QueryBool("topic"),
115+
Collaborate: util.OptionalBoolNone,
116+
Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
117+
UserIsAdmin: ctx.IsUserSiteAdmin(),
118+
UserID: ctx.Data["SignedUserID"].(int64),
119+
StarredByID: ctx.QueryInt64("starredBy"),
120+
IncludeDescription: ctx.QueryBool("includeDesc"),
116121
}
117122

118123
if ctx.QueryBool("exclusive") {
@@ -157,7 +162,7 @@ func Search(ctx *context.APIContext) {
157162
}
158163

159164
var err error
160-
repos, count, err := models.SearchRepositoryByName(opts)
165+
repos, count, err := models.SearchRepository(opts)
161166
if err != nil {
162167
ctx.JSON(500, api.SearchError{
163168
OK: false,

templates/swagger/v1_json.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,12 @@
11541154
"description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.",
11551155
"name": "order",
11561156
"in": "query"
1157+
},
1158+
{
1159+
"type": "boolean",
1160+
"description": "include search of keyword within repository description",
1161+
"name": "includeDesc",
1162+
"in": "query"
11571163
}
11581164
],
11591165
"responses": {

0 commit comments

Comments
 (0)