Skip to content

Commit 92c49aa

Browse files
peter scholzLeFnord
peter scholz
authored andcommitted
fixes ruby-grape#539 and ruby-grape#542; not all of 530 was commited (ruby-grape#544)
- adds changelog entry
1 parent 01aea7e commit 92c49aa

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
* Your contribution here.
1010

1111

12+
### 0.25.2 (November 30, 2016)
13+
14+
#### Fixes
15+
16+
* [#544](https://github.com/ruby-grape/grape-swagger/pull/544): Fixes #539 and #542; not all of 530 was commited - [@LeFnord](https://github.com/LeFnord).
17+
1218
### 0.25.1 (November 29, 2016)
1319

1420
#### Features

lib/grape-swagger/doc_methods/move_params.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def should_correct_array?(param)
2828

2929
def correct_array_param(param)
3030
param.first[:schema] = { type: param.first.delete(:type), items: param.first.delete(:items) }
31+
32+
param
3133
end
3234

3335
def parent_definition_of_params(params, route)

spec/issues/539_array_post_body.rb renamed to spec/issues/539_array_post_body_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
require 'grape-entity'
33
require 'grape-swagger-entity'
44

5-
describe '#427 nested entity given as string' do
5+
describe '#539 post params given as array' do
66
let(:app) do
77
Class.new(Grape::API) do
8-
namespace :issue_427 do
8+
namespace :issue_539 do
99
class Element < Grape::Entity
1010
expose :id
1111
expose :description
@@ -35,7 +35,7 @@ class ArrayOfElements < Grape::Entity
3535
JSON.parse(last_response.body)
3636
end
3737

38-
let(:parameters) { subject['paths']['/issue_427']['post']['parameters'] }
38+
let(:parameters) { subject['paths']['/issue_539']['post']['parameters'] }
3939
let(:definitions) { subject['definitions'] }
4040

4141
specify do
@@ -48,7 +48,9 @@ class ArrayOfElements < Grape::Entity
4848
}
4949
]
5050
)
51+
end
5152

53+
specify do
5254
expect(definitions).to eql(
5355
'Element' => {
5456
'type' => 'object',
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'spec_helper'
2+
require 'grape-entity'
3+
require 'grape-swagger-entity'
4+
5+
describe '#542 array of type in post params' do
6+
let(:app) do
7+
Class.new(Grape::API) do
8+
namespace :issue_542 do
9+
params do
10+
requires :logs, type: Array[String], documentation: { param_type: 'body' }
11+
end
12+
13+
post do
14+
present params
15+
end
16+
end
17+
18+
add_swagger_documentation format: :json
19+
end
20+
end
21+
22+
subject do
23+
get '/swagger_doc'
24+
JSON.parse(last_response.body)
25+
end
26+
27+
let(:parameters) { subject['paths']['/issue_542']['post']['parameters'] }
28+
29+
specify do
30+
expect(parameters).to eql(
31+
[
32+
{
33+
'in' => 'body',
34+
'name' => 'logs',
35+
'required' => true,
36+
'schema' => {
37+
'type' => 'array',
38+
'items' => {
39+
'type' => 'string'
40+
}
41+
}
42+
}
43+
]
44+
)
45+
end
46+
end

0 commit comments

Comments
 (0)