ruby-grape / grape-entity

An API focused facade that sits on top of an object model.
MIT License
721 stars 153 forks source link

Sending an array of hash #344

Open DamienCompere opened 3 years ago

DamienCompere commented 3 years ago

When I try to send an array of hash, I have the error instance of ActiveSupport::HashWithIndifferentAccess

Here is my model : expose :book, documentation: { type: Array[Hash] } And in my controller I have nested attributes like this : requires :collection, type: Hash do optional :book, type: Array do requires :id, type: String requires :price, type: BigDecimal end end

When I check in my console the params book, I have an array with a hash : [{"id"=>"351a7eaf-cf93-4f89-9f3a-b2cce4c07a70", "amount"=>0.23e2}] But it returns the error Collection::book(#11898309) expected, got {"id"=>"351a7eaf-cf93-4f89-9f3a-b2cce4c07a70", "amount"=>0.23e2} which is an instance of ActiveSupport::HashWithIndifferentAccess(#510440) Do you know what's wrong here ?

LeFnord commented 3 years ago

please use ruby-grape for questions