Grape: Params 'as' option fails within 'given' block

Created on 17 Jul 2018  路  5Comments  路  Source: ruby-grape/grape

The parameter alias as option is ignored when a parameter is declared inside a given block

params do
  optional :label, as: :vertex_label, type: String
  given :label do
    optional :property, as: :vertex_property, type: String
  end
end

When a route with this params declaration is triggered, declared(params) evaluates to:
{ "vertex_label" => "MyLabel", "property" => "MyProperty" }

I expect the property parameter to be aliased to vertex_property in declared params, but this does not happen

bug?

All 5 comments

Looks legit, try writing a spec for it?

Added fix to the PR

Closing via https://github.com/ruby-grape/grape/pull/1771. Thanks @jereynolds!

Do you know what the expected time until the fix is released is?

Nope, but there're a bunch of changes so I'll do a release when I get to it or another maintainer beats me to it, https://github.com/ruby-grape/grape/issues/1773.

Was this page helpful?
0 / 5 - 0 ratings