Skip to content

Using entities as grape params cause invalid fields? #211

Open
@raintears

Description

@raintears

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions