summaryrefslogtreecommitdiff
path: root/lib/api/pagination_params.rb
blob: f566eb3ed2b12aaa88d31f859a3626f4cafcc454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module API
  # Concern for declare pagination params.
  #
  # @example
  #   class CustomApiResource < Grape::API
  #     include PaginationParams
  #
  #     params do
  #       use :pagination
  #     end
  #   end
  module PaginationParams
    extend ActiveSupport::Concern

    included do
      helpers do
        params :pagination do
          optional :page, type: Integer, default: 1, desc: 'Current page number'
          optional :per_page, type: Integer, default: 20, desc: 'Number of items per page'
        end
      end
    end
  end
end