Skip to content

JSON:API: pagination links duplicate the page parameter and next does not advance #8747

Closed

Description

@soyuka

API Platform version(s) affected

5.0.4 (same on 4.4.5 and main)

Description

With a custom page_parameter_name, the links contain the original page[number] and a flat number, and the flat one wins when the link is followed, so next stays on the same page.

api_platform:
    formats: { jsonapi: ['application/vnd.api+json'] }
    collection:
        pagination: { page_parameter_name: number, items_per_page_parameter_name: size }

GET /books?page[number]=2&page[size]=3 (10 items) answers:

"self": "/books?page[number]=2&page[size]=3&number=2",
"next": "/books?page[number]=2&page[size]=3&number=3"

Following next returns meta.currentPage: 2. Expected "next": "/books?page[number]=3&page[size]=3".

With the default config, GET /books?page[page]=2 yields "next": "/books?page=3". The page family is reserved by the spec for pagination, so the links should keep the bracket form the client used: https://jsonapi.org/format/1.1/#fetching-pagination

Cause: IriHelper::parseIri() only unsets the flat $pageParameterName (src/Metadata/Util/IriHelper.php:50), createIri() then writes it flat (:64) next to the untouched page[...] (called from src/JsonApi/Serializer/CollectionNormalizer.php:44). On the way in, JsonApiProvider hoists page[number] into number, and the raw flat number of the link loses against it (src/JsonApi/State/JsonApiProvider.php:101, :111 on 5.0).

Suggested fix: in the JSON:API collection normalizer, remove page[<name>] from the parsed query and write the new page back as page[<name>].

Activity

  1. added 2 commits that reference this issue on Oct 22, 2026
    b2652bf
    a446a4f
  2. soyuka commented on Oct 22, 2026

    @soyuka
    MemberAuthor

    fixed by #8753 (5.0)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions