extract helper for search scope api param
This commit is contained in:
parent
4c684a8d5c
commit
c36d98501b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue