As my API will be used by a frontend app I wanted to set per_page_param as camel-cased :perPage instead of the default :per_page.
I used the described in the documentation configuration method which resulted in ArgumentError: comparison of Integer with String failed. After checking swagger docs I noticed that endpoint is still accepting only :per_page while pagination method is trying to fetch :perPage value from params.
I tried to add optional :perPage, type: Integer to my endpoint params, but now both :perPage and :per_page were available in the swagger docs.
I ended up in monkey patching def self.paginate(options = {}) from lib/grape/pagination.rb to use :perPage in line 49. I don't think that in the current way as per_page_param= is evaluated we can read the key from any variable (it is assigning a lambda to @per_page_param).
Maybe we can add @per_page_param_key to allow reading configured key? Same goes for the page_param configuration.
grape: 1.3.0
pagy: 3.6.0
api-pagination 4.8.2
As my API will be used by a frontend app I wanted to set
per_page_paramas camel-cased:perPageinstead of the default:per_page.I used the described in the documentation configuration method which resulted in
ArgumentError: comparison of Integer with String failed. After checking swagger docs I noticed that endpoint is still accepting only:per_pagewhile pagination method is trying to fetch:perPagevalue from params.I tried to add
optional :perPage, type: Integerto my endpoint params, but now both:perPageand:per_pagewere available in the swagger docs.I ended up in monkey patching
def self.paginate(options = {})fromlib/grape/pagination.rbto use:perPagein line 49. I don't think that in the current way asper_page_param=is evaluated we can read the key from any variable (it is assigning a lambda to@per_page_param).Maybe we can add
@per_page_param_keyto allow reading configured key? Same goes for thepage_paramconfiguration.grape: 1.3.0
pagy: 3.6.0
api-pagination 4.8.2