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
# 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
......
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