You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to write something along the lines of
params do
requires :request, type:Hash, desc: 'Request Wrapper required for all API requests', documentation:{example: 'request:{}'} do
requires :dealer_id, type:Integer,default: 0, desc: 'Dealer Id Number', documentation:{example: 100001}
end
end
Which seemed like it should work appropriately as I need to document the wrapper as well as the parameters inside it but I was receiving an standard ArgumentError. So I started digging through the source and traced it all down to Grape::Validations::ParamsScope#new_scope
My issue is why are we checking to make sure that my options are a subset? of a single element wouldn't equality work better here? Unless of course we are looking to see if [:type].to_set is a #subset? of my opts which seems more like the intended behavior in which case I am proposing changing #new_scope to
This would then allow me to use #requires with doc_attrs and a block. Does this some how cause interference elsewhere that I am overlooking? Can someone explain to me why you would check to see if {type: Array}.keys.to_set is a subset of [:type].to_set when this truely evaluates to {type: Array}.keys.to_set == [:type].to_set? because a subset of a single item must be equal to that single item.
The text was updated successfully, but these errors were encountered:
engineersmnky
changed the title
requires with block and and doc_attrs
requires doc_attrs and a block
Sep 10, 2014
I was trying to write something along the lines of
Which seemed like it should work appropriately as I need to document the wrapper as well as the parameters inside it but I was receiving an standard ArgumentError. So I started digging through the source and traced it all down to
Grape::Validations::ParamsScope#new_scope
My issue is why are we checking to make sure that my options are a
subset?
of a single element wouldn't equality work better here? Unless of course we are looking to see if[:type].to_set
is a#subset?
of my opts which seems more like the intended behavior in which case I am proposing changing#new_scope
toThis would then allow me to use
#requires
withdoc_attrs
and a block. Does this some how cause interference elsewhere that I am overlooking? Can someone explain to me why you would check to see if{type: Array}.keys.to_set
is a subset of[:type].to_set
when this truely evaluates to{type: Array}.keys.to_set == [:type].to_set
? because a subset of a single item must be equal to that single item.The text was updated successfully, but these errors were encountered: