Search code examples
configurationpaginationmicronaut

Can I disable max-page-size completely for pagination in micronaut?


In my configuration file, when I remove the max-page-size parameter, Micronaut still uses a default value of 100 (as one would expect after reading the documentation). However, I would like to remove this limitation completely. The most obvious way would be just setting the value to a absurdly high number like 9999999999 but I'm looking for a more elegant solution.

I haven't found any special configuration to tell micronaut to do so, so I am considering extending the Pageable class to see if overriding some getter I can bypass the default limit.

Is this possible at all?


Solution

  • The best workaround I've found is setting the limit to the special YAML value for infinity: .inf.

    micronaut:
      data:
        pageable:
          max-page-size: .inf
    

    This way the value parsed by Micronaut is the maximum int value 2147483647, which is more than enough to consider the page size unlimited.