Skip to content

4.7.1

Compare
Choose a tag to compare
@davidcelis davidcelis released this 25 Apr 17:43
· 51 commits to master since this release

Add an :enforce_max_per_page option to pagination in Grape APIs:

class MoviesAPI < Grape::API
  format :json

  desc 'Return a paginated set of movies'
  paginate per_page: 25, max_per_page: 100, enforce_max_per_page: true
  get do
    # If a client tries to make a request with a `per_page` param that is above 100,
    # no movies will be returned. Instead, a client error will be returned.
    paginate Movie.all
  end
end