diff --git a/lib/jsonapi/utils/response/formatters.rb b/lib/jsonapi/utils/response/formatters.rb index 00f4f2f..7cae6cf 100644 --- a/lib/jsonapi/utils/response/formatters.rb +++ b/lib/jsonapi/utils/response/formatters.rb @@ -134,6 +134,12 @@ def build_response_document(object, options) # @api private def build_collection_result(object, options) records = build_collection(object, options) + + unless options.key?(:count) + limit = page_params['size'].to_i.nonzero? || JSONAPI.configuration.default_page_size + options[:count] = records.size if records.size < limit + end + result_options = result_options(object, options) if related_resource_operation?(options)