Skip to content

Grape DSL: Return different entities #1513

Open
@Razer6

Description

@Razer6

Consider an API endpoint which returns a different entity depending on the current user. Is it possible to specify those different return entities in Grape DSL? Something like the following?

desc 'Return user details' do
  success Entities::BasicUser, Entities::FullUser
end
get 'users' do
  if is_admin
    present users, with: Entities::FullUser
  else
    present users, with: Entities::BasicUser
  end
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions