2

I'm defining params for a grape route like this

    params do
      requires :array, type: Array do
          requires :foo, type: String
          requires :bar, type: String
      end
    end

The data for this endpoint would be {"array": [{"foo": "123", "bar": "456"}]}.

How can I get rid of the additional "array"? The data should look like this [{"foo": "123", "bar": "456"}]

I can't define a type Array on params.

23tux
  • 14,104
  • 15
  • 88
  • 187

1 Answers1

0

You can use groups to do this, more info at https://github.com/ruby-grape/grape#group-options

e.g.: params do group :array, type: Array do requires :foo, type: String requires :bar, type: String ... end end

Marcelo Boeira
  • 860
  • 8
  • 22