Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorAlexis Reigel <alexis.reigel.ext@siemens.com>2018-12-19 16:49:46 +0300
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2019-03-14 20:30:29 +0300
commitc36d98501b86e12d03d9a66d3ada9688531f6cd8 (patch)
tree20f2fead3c5218e4718b0dc638e232f9e933fae8 /lib/api
parent4c684a8d5c5432a720577486451830f085994fd3 (diff)
extract helper for search scope api param
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/search.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/api/search.rb b/lib/api/search.rb
index 431c45a386a..01eaf2f142a 100644
--- a/lib/api/search.rb
+++ b/lib/api/search.rb
@@ -52,6 +52,15 @@ module API
# Defining this method here as a noop allows us to easily extend it in
# EE, without having to modify this file directly.
end
+
+ params :scope do |options|
+ values = SCOPE_ENTITY.stringify_keys.slice(*options[:values]).keys
+
+ requires :scope,
+ type: String,
+ desc: 'The scope of the search',
+ values: values
+ end
end
resource :search do
@@ -60,10 +69,7 @@ module API
end
params do
requires :search, type: String, desc: 'The expression it should be searched for'
- requires :scope,
- type: String,
- desc: 'The scope of the search',
- values: Helpers::SearchHelpers.global_search_scopes
+ use :scope, values: Helpers::SearchHelpers.global_search_scopes
use :pagination
end
get do
@@ -80,10 +86,7 @@ module API
params do
requires :id, type: String, desc: 'The ID of a group'
requires :search, type: String, desc: 'The expression it should be searched for'
- requires :scope,
- type: String,
- desc: 'The scope of the search',
- values: Helpers::SearchHelpers.group_search_scopes
+ use :scope, values: Helpers::SearchHelpers.group_search_scopes
use :pagination
end
get ':id/(-/)search' do
@@ -100,10 +103,7 @@ module API
params do
requires :id, type: String, desc: 'The ID of a project'
requires :search, type: String, desc: 'The expression it should be searched for'
- requires :scope,
- type: String,
- desc: 'The scope of the search',
- values: Helpers::SearchHelpers.project_search_scopes
+ use :scope, Helpers::SearchHelpers.project_search_scopes
use :pagination
end
get ':id/(-/)search' do