Skip to content

Commit d2b9f67

Browse files
korstiaanLeFnord
authored andcommitted
Add support for 'brackets' collection format (#622)
* Add support for 'brackets' collection format * Update changelog.md
1 parent bb68d90 commit d2b9f67

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#### Features
44

5-
* Your contribution here.
5+
* [#622](https://github.com/ruby-grape/grape-swagger/pull/622): Add support for 'brackets' collection format - [@korstiaan](https://github.com/korstiaan).
66

77
#### Fixes
88

lib/grape-swagger/doc_methods/data_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def mapping(value)
8080
end
8181

8282
def collections
83-
%w[csv ssv tsv pipes multi]
83+
%w[csv ssv tsv pipes multi brackets]
8484
end
8585
end
8686

spec/swagger_v2/params_array_collection_fromat_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def app
3131
{ 'declared_params' => declared(params) }
3232
end
3333

34+
params do
35+
optional :array_of_strings, type: Array[String], desc: 'array in brackets collection format', documentation: { collectionFormat: 'brackets' }
36+
end
37+
38+
get '/array_of_strings_brackets_collection_format' do
39+
{ 'declared_params' => declared(params) }
40+
end
41+
3442
add_swagger_documentation
3543
end
3644
end
@@ -65,6 +73,21 @@ def app
6573
end
6674
end
6775

76+
describe 'documentation for array parameters in brackets collectionFormat set from documentation' do
77+
subject do
78+
get '/swagger_doc/array_of_strings_brackets_collection_format'
79+
JSON.parse(last_response.body)
80+
end
81+
82+
specify do
83+
expect(subject['paths']['/array_of_strings_brackets_collection_format']['get']['parameters']).to eql(
84+
[
85+
{ 'in' => 'formData', 'name' => 'array_of_strings', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => false, 'collectionFormat' => 'brackets', 'description' => 'array in brackets collection format' }
86+
]
87+
)
88+
end
89+
end
90+
6891
describe 'documentation for array parameters with collectionFormat set to invalid option' do
6992
subject do
7093
get '/swagger_doc/array_of_strings_invalid_collection_format'

0 commit comments

Comments
 (0)