Skip to content

Commit eb94a31

Browse files
authored
Fix value of enum to be Array (#850)
1 parent 14adf93 commit eb94a31

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#### Fixes
88

9+
* [#850](https://github.com/ruby-grape/grape-swagger/pull/850): Fix value of `enum` to be `Array` - [@takahashim](https://github.com/takahashim)
910
* Your contribution here.
1011

1112

UPGRADING.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Upgrading to >= 1.4.2
44

55
- `additionalProperties` has been deprecated and will be removed in a future version of `grape-swagger`. It has been replaced with `additional_properties`.
6+
- The value of the `enum` attribute is now always an Array. If it has only one value, it will be a one-element Array.
67

78
### Upgrading to >= 1.4.0
89

lib/grape-swagger/doc_methods/parse_params.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@ def parse_enum_or_range_values(values)
163163
parse_enum_or_range_values(values.call) if values.parameters.empty?
164164
when Range
165165
parse_range_values(values) if values.first.is_a?(Integer)
166+
when Array
167+
{ enum: values }
166168
else
167-
{ enum: values } if values
169+
{ enum: [values] } if values
168170
end
169171
end
170172

spec/swagger_v2/param_values_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def first_parameter_info(request)
141141
'name' => 'letter',
142142
'type' => 'string',
143143
'required' => true,
144-
'enum' => 'string'
144+
'enum' => %w[string]
145145
}]
146146
end
147147
end

0 commit comments

Comments
 (0)