Paging
Paging is the standard request-side pagination params class.
Bind it with @RequestBean Paging and it captures the page/size/order query parameters, then converts to a Micronaut Pageable on demand.
Query parameters
| Parameter | Default | Notes |
|---|---|---|
|
|
Zero-based page index. Clamped to |
|
|
Page size, defaulting to |
|
none |
Field to order by. Validate it against an allow-list — see Query-param smuggle-rejection. |
|
|
|
Converting to a Pageable
toPageable() clamps page and size and applies ordering only when orderByField is set:
Pageable pageable = paging.toPageable();
toPageableWithDefaults(field, direction) supplies a default order, but only when the client did not request one:
Pageable pageable = paging.toPageableWithDefaults("createdAt", Direction.DESC);
Producing a paginated envelope
Envelopes.slice(…) turns a Micronaut Page or Slice into a SliceEnvelope, setting content, pageNumber, and pageSize:
var page = service.find(query, paging.toPageable());
return Envelopes.slice(page, tenantId);
pageNumber is zero-based, mirroring Micronaut’s Page/Slice serialization.