grape-entity icon indicating copy to clipboard operation
grape-entity copied to clipboard

Using entities as grape params cause invalid fields?

Open raintears opened this issue 9 years ago • 1 comments

Hi this is my code. When I'm using entities as grape params, whenever i do a post request, it returns me name invalid, email invalid, id invalid, etc. Everything is invalid, is there anything i did wrong here? I couldn't find a lot of documentation on this though

desc 'Create a customer.' params { requires :none, except: [:name, :email], using: Entities::Customer.documentation.except(:id) } post do present Customer.create! params, with: Entities::Customer end

class Customer< Grape::Entity expose :id, documentation: { type: "string" } do |model| model.id.to_s end expose :name, documentation: { type: "string" } expose :contact_details do expose :emailaddress, documentation: { type: "string" } expose :address, documentation: { type: "string" } expose :phone, documentation: { type: "string" } end

raintears avatar Mar 09 '16 10:03 raintears

I am no expert on this, but requires :none looks suspicious, that is supposed to make :name and :email required).

What do you POST? Care to write a small repro spec?

dblock avatar Mar 13 '16 22:03 dblock