Fix issue where array params are sometimes omitted when array_use_braces is true#957
Fix issue where array params are sometimes omitted when array_use_braces is true#957olivier-thatch wants to merge 3 commits intoruby-grape:masterfrom
array_use_braces is true#957Conversation
|
CI was fixed in #958, rebase please? |
e4b3778 to
eba362d
Compare
array_use_braces is true
|
Hi @olivier-thatch, a quick fix for this PR could be: diff --git a/lib/grape-swagger/doc_methods/move_params.rb b/lib/grape-swagger/doc_methods/move_params.rb
index c8417ce..12c6477 100644
--- a/lib/grape-swagger/doc_methods/move_params.rb
+++ b/lib/grape-swagger/doc_methods/move_params.rb
@@ -136,7 +136,7 @@ module GrapeSwagger
return if value.blank?
definition[:required] ||= []
- definition[:required].push(*value)
+ definition[:required].push(*value).uniq!
end
def build_body_parameter(name, options)I considered using a |
d19daf7 to
003b77f
Compare
|
I looked more closely at the PR and noticed we have incorrect behavior for nested arrays. The type We need to either fix this to properly support multi-dimensional arrays or clearly document that they aren’t supported. |
Fixes #952.
The fix consists of removing the
[]suffix at the end of a parameter's name if the parameter is an array and it's a body param.This fix is very hacky: ideally,
[]shouldn't be added in the first place. But I don't think that can be achieved without significantly refactoring the code.@dblock @numbata Curious if you have any thoughts on this approach.