diff options
author | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2018-12-19 14:49:46 +0100 |
---|---|---|
committer | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2019-03-14 18:30:29 +0100 |
commit | c36d98501b86e12d03d9a66d3ada9688531f6cd8 (patch) | |
tree | 20f2fead3c5218e4718b0dc638e232f9e933fae8 /lib | |
parent | 4c684a8d5c5432a720577486451830f085994fd3 (diff) | |
download | gitlab-ce-c36d98501b86e12d03d9a66d3ada9688531f6cd8.tar.gz |
extract helper for search scope api param
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/search.rb | 24 |
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 |