Skip to content

Commit dc2e25b

Browse files
frodrigoLeFnord
authored andcommitted
Fix regex for Array and Multi Type in doc_methods (ruby-grape#479)
1 parent 6db53ae commit dc2e25b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
* [#476](https://github.com/ruby-grape/grape-swagger/pull/476): Fixes for handling the parameter type when body parameters are defined inside desc block - [@anakinj](https://github.com/anakinj).
1010
* [#478](https://github.com/ruby-grape/grape-swagger/pull/478): Refactors building of properties, corrects documentation of array items - [@LeFnord](https://github.com/LeFnord).
11+
* [#479](https://github.com/ruby-grape/grape-swagger/pull/479): Fix regex for Array and Multi Type in doc_methods. Parsing of "[APoint]" should return "APoint" - [@frodrigo](https://github.com/frodrigo).
1112
* Your contribution here.
1213

1314
### 0.22.0 (July 12, 2016)

lib/grape-swagger/doc_methods/data_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def call(value)
3232
def parse_multi_type(raw_data_type)
3333
case raw_data_type
3434
when /\A\[.*\]\z/
35-
raw_data_type.gsub(/[(\A\[)(\s+)(\]\z)]/, '').split(',').first
35+
raw_data_type.gsub(/[\[\s+\]]/, '').split(',').first
3636
when Array
3737
raw_data_type.first
3838
else

spec/lib/data_type_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
it { expect(subject).to eql 'string' }
2525
end
2626

27+
describe 'Multi types in a string stating with A' do
28+
let(:value) { { type: '[Apple, Orange]' } }
29+
30+
it { expect(subject).to eql 'Apple' }
31+
end
32+
2733
describe 'Multi types in array' do
2834
let(:value) { { type: [String, Integer] } }
2935

0 commit comments

Comments
 (0)