Skip to content

Commit 0cd860b

Browse files
author
Doug Smith
committed
chore: add NestedParamPaginator to README and CHANGELOG
1 parent cc4b697 commit 0cd860b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- [#348](https://github.com/JsonApiClient/json_api_client/pull/348) - add NestedParamPaginator to address inconsistency in handling of pagination query string params (issue [#347](https://github.com/JsonApiClient/json_api_client/issues/347)).
6+
57
## 1.12.0
68

79
- [#345](https://github.com/JsonApiClient/json_api_client/pull/345) - track the real HTTP reason of ApiErrors

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,20 @@ class MyApi::Base < JsonApiClient::Resource
599599
end
600600
```
601601
602+
### NestedParamPaginator
603+
604+
The current default `JsonApiClient::Paginating::Paginator` is inconsistent in the way it handles pagination query string params. The JSON:API spec seems to favor a nested structure like `page[page]=1&page[per_page]=10`. However, the default paginator doesn't always return or enforce that nested structure. See issue [#347](https://github.com/JsonApiClient/json_api_client/issues/347) for more details.
605+
606+
If you'd like a more consistent pagination query string param behavior, assign the `JsonApiClient::Paginating::NestedParamPaginator` to your resource as a custom paginator, like so:
607+
608+
```ruby
609+
class Order < JsonApiClient::Resource
610+
self.paginator = JsonApiClient::Paginating::NestedParamPaginator
611+
end
612+
```
613+
614+
You can also extend `NestedParamPaginator` in your custom paginators or assign the `page_param` or `per_page_param` as with the default version above.
615+
602616
### Custom type
603617
604618
If your model must be named differently from classified type of resource you can easily customize it.

0 commit comments

Comments
 (0)