-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set query parameter for array of primitive types (#929)
* Set query parameter for array of primitive types * Update PR number in changelog * refactor param_type method to handle array params. --------- Co-authored-by: Eugene Lim <limzhiweieugene@gmail.com>
- Loading branch information
1 parent
e7856de
commit 95be315
Showing
5 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe '#883 Group Params as Array' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
namespace :issue_883 do | ||
params do | ||
requires :array_of_string, type: [String] | ||
requires :array_of_integer, type: [Integer] | ||
end | ||
get '/get_primitive_array_parameters' do | ||
'accepts array query parameters of primitive value types' | ||
end | ||
|
||
params do | ||
requires :array_of, type: Array, documentation: { type: 'link', is_array: true } | ||
end | ||
get '/get_object_array_parameters' do | ||
'does not accept array query parameters of object value types' | ||
end | ||
end | ||
add_swagger_documentation | ||
end | ||
end | ||
|
||
describe 'retrieves the documentation for typed group range parameters' do | ||
subject do | ||
get '/swagger_doc' | ||
JSON.parse(last_response.body) | ||
end | ||
|
||
specify do | ||
expect(subject['paths']['/issue_883/get_primitive_array_parameters']['get']['parameters']).to eql( | ||
[ | ||
{ 'in' => 'query', 'name' => 'array_of_string', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }, | ||
{ 'in' => 'query', 'name' => 'array_of_integer', 'type' => 'array', 'items' => { 'type' => 'integer', 'format' => 'int32' }, 'required' => true } | ||
] | ||
) | ||
expect(subject['paths']['/issue_883/get_object_array_parameters']['get']['parameters']).to eql( | ||
[{ 'in' => 'formData', 'items' => { 'type' => 'string' }, 'name' => 'array_of', 'required' => true, 'type' => 'array' }] | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters