Skip to content

fix: use JSON:API compliant conversion#7889

Open
elfin-sbreuers wants to merge 1 commit intoapi-platform:4.3from
elfin-sbreuers:fix_pagination_jsonapi
Open

fix: use JSON:API compliant conversion#7889
elfin-sbreuers wants to merge 1 commit intoapi-platform:4.3from
elfin-sbreuers:fix_pagination_jsonapi

Conversation

@elfin-sbreuers
Copy link
Copy Markdown
Contributor

Following recommendations from here

https://jsonapi.org/format/#fetching-pagination

while being close to the ways used internally in api-platform.

===

This addresses some of the issues discussed in this issue.

Going forward, there are two possible approaches:

  • Support the default pagination parameters of API Platform (page, itemsPerPage, pagination) alongside filters and the JSON:API page[...] structure
  • Or adopt the JSON:API pagination format exclusively

Depending on the chosen approach, the links section needs to be handled accordingly:

  • If JSON:API-style pagination is used, the links key should be updated to reflect it
  • If API Platform parameters are also supported at the top level, the existing links handling can remain unchanged

This ultimately comes down to a design decision based on the desired level of compatibility and consistency.

Following recommendations from here

https://jsonapi.org/format/#fetching-pagination

while being close to the ways used internally in api-platform.
@soyuka
Copy link
Copy Markdown
Member

soyuka commented Mar 28, 2026

I left a detailed response on #7888 explaining the situation.

In short: the JSON:API spec is explicitly agnostic about pagination strategy — page[number]/page[size] are examples, not requirements. API Platform uses page[page]/page[itemsPerPage] which is equally valid.

Hardcoding the mapping numberpage and sizeitemsPerPage in JsonApiProvider would be opinionated and couples the provider to one specific pagination vocabulary. Users who want custom names like page[number]/page[size] can already achieve this via QueryParameter with a provider callable — see the example in my comment on the issue.

I don't think we should merge this as-is.

Comment mostly generated with Claude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants