Commit c36d9850 authored by Alexis Reigel's avatar Alexis Reigel

extract helper for search scope api param

parent 4c684a8d
...@@ -52,6 +52,15 @@ module API ...@@ -52,6 +52,15 @@ module API
# Defining this method here as a noop allows us to easily extend it in # Defining this method here as a noop allows us to easily extend it in
# EE, without having to modify this file directly. # EE, without having to modify this file directly.
end 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 end
resource :search do resource :search do
...@@ -60,10 +69,7 @@ module API ...@@ -60,10 +69,7 @@ module API
end end
params do params do
requires :search, type: String, desc: 'The expression it should be searched for' requires :search, type: String, desc: 'The expression it should be searched for'
requires :scope, use :scope, values: Helpers::SearchHelpers.global_search_scopes
type: String,
desc: 'The scope of the search',
values: Helpers::SearchHelpers.global_search_scopes
use :pagination use :pagination
end end
get do get do
...@@ -80,10 +86,7 @@ module API ...@@ -80,10 +86,7 @@ module API
params do params do
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
requires :search, type: String, desc: 'The expression it should be searched for' requires :search, type: String, desc: 'The expression it should be searched for'
requires :scope, use :scope, values: Helpers::SearchHelpers.group_search_scopes
type: String,
desc: 'The scope of the search',
values: Helpers::SearchHelpers.group_search_scopes
use :pagination use :pagination
end end
get ':id/(-/)search' do get ':id/(-/)search' do
...@@ -100,10 +103,7 @@ module API ...@@ -100,10 +103,7 @@ module API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
requires :search, type: String, desc: 'The expression it should be searched for' requires :search, type: String, desc: 'The expression it should be searched for'
requires :scope, use :scope, Helpers::SearchHelpers.project_search_scopes
type: String,
desc: 'The scope of the search',
values: Helpers::SearchHelpers.project_search_scopes
use :pagination use :pagination
end end
get ':id/(-/)search' do get ':id/(-/)search' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment