I have a Rails 5.1 app using the jsonapi-resources gem. In the config I set:
config.top_level_links_include_pagination = true
config.top_level_meta_include_page_count = true
which results in the following output:
"meta": {
"page-count": null
},
"links": {
"first": "http://localhost:3000/api/v1/smth?page%5Bnumber%5D=1&page%5Bsize%5D=15",
"next": "http://localhost:3000/api/v1/smth?page%5Bnumber%5D=2&page%5Bsize%5D=15",
"last": "http://localhost:3000/api/v1/smth?page%5Bnumber%5D=9&page%5Bsize%5D=15"
}
Now, what puzzles me, is that it obviously knows that there are 9 pages (see last pagination link), but the page count in the meta section is empty.
Any ideas why this is happening and how it can be fixed?
config/initializers/json_api.rb
JSONAPI.configure do |config|
config.default_paginator = :paged
config.default_page_size = 15
config.maximum_page_size = 30
config.allow_sort = true
config.allow_filter = true
config.top_level_meta_include_record_count = true
config.top_level_links_include_pagination = true
config.top_level_meta_include_page_count = true
config.resource_cache = Rails.cache
end