-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
align array params for post, put request (#553)
- adds changelog entry
- Loading branch information
peter scholz
authored
Dec 16, 2016
1 parent
8c90a9c
commit 17db1b8
Showing
10 changed files
with
154 additions
and
11 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
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
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,142 @@ | ||
require 'spec_helper' | ||
|
||
describe '#553 array of type in post/put params' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
namespace :in_form_data do | ||
desc 'create foo' | ||
params do | ||
requires :guid, type: Array[String] | ||
end | ||
post do | ||
# your code goes here | ||
end | ||
|
||
desc 'put specific foo' | ||
params do | ||
requires :id | ||
requires :guid, type: Array[String] | ||
end | ||
put ':id' do | ||
# your code goes here | ||
end | ||
end | ||
|
||
namespace :in_body do | ||
desc 'create foo' | ||
params do | ||
requires :guid, type: Array[String], documentation: { param_type: 'body' } | ||
end | ||
post do | ||
# your code goes here | ||
end | ||
|
||
desc 'put specific foo' | ||
params do | ||
requires :id | ||
requires :guid, type: Array[String], documentation: { param_type: 'body' } | ||
end | ||
put ':id' do | ||
# your code goes here | ||
end | ||
end | ||
|
||
add_swagger_documentation format: :json | ||
end | ||
end | ||
|
||
subject do | ||
get '/swagger_doc' | ||
JSON.parse(last_response.body) | ||
end | ||
|
||
describe 'type for Array specified' do | ||
describe 'in formData' do | ||
describe 'post request' do | ||
let(:params) { subject['paths']['/in_form_data']['post']['parameters'] } | ||
|
||
specify do | ||
expect(params).to eql([{ | ||
'in' => 'formData', | ||
'name' => 'guid', | ||
'type' => 'array', | ||
'items' => { 'type' => 'string' }, | ||
'required' => true | ||
}]) | ||
end | ||
end | ||
|
||
describe 'put request' do | ||
let(:params) { subject['paths']['/in_form_data/{id}']['put']['parameters'] } | ||
|
||
specify do | ||
expect(params).to eql( | ||
[ | ||
{ | ||
'in' => 'path', | ||
'name' => 'id', | ||
'type' => 'string', | ||
'required' => true | ||
}, | ||
{ | ||
'in' => 'formData', | ||
'name' => 'guid', | ||
'type' => 'array', | ||
'items' => { 'type' => 'string' }, | ||
'required' => true | ||
} | ||
] | ||
) | ||
end | ||
end | ||
end | ||
|
||
describe 'in body' do | ||
describe 'post request' do | ||
let(:params) { subject['paths']['/in_body']['post']['parameters'] } | ||
|
||
specify do | ||
expect(params).to eql( | ||
[ | ||
{ | ||
'in' => 'body', | ||
'name' => 'guid', | ||
'required' => true, | ||
'schema' => { | ||
'type' => 'array', | ||
'items' => { 'type' => 'string' } | ||
} | ||
} | ||
] | ||
) | ||
end | ||
end | ||
|
||
describe 'put request' do | ||
let(:params) { subject['paths']['/in_body/{id}']['put']['parameters'] } | ||
|
||
specify do | ||
expect(params).to eql( | ||
[ | ||
{ | ||
'in' => 'path', | ||
'name' => 'id', | ||
'type' => 'string', | ||
'required' => true | ||
}, | ||
{ | ||
'in' => 'body', | ||
'name' => 'guid', | ||
'required' => true, | ||
'schema' => { | ||
'type' => 'array', | ||
'items' => { 'type' => 'string' } | ||
} | ||
} | ||
] | ||
) | ||
end | ||
end | ||
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