Skip to content

server/app/interfaces/base: Allow pagination JsonResponse with empty cursor #519

@hpoeche

Description

@hpoeche

Currently the presence of a cursor value in the creation of a JsonResponse determines, if the
response body consists purely of the data or if a paging_metadata element is added.

def serialize(self, obj: ResponseData, cursor: Optional[int], stripped: bool) -> str:
if cursor is None:
data = obj
else:
data = {
"paging_metadata": {"cursor": str(cursor)},
"result": obj
}

The spec defines in contrast to this, that the response to a pagination request must always contain the paging_metadata element. If the end of the result set has been reached with this request, the cursor attribute has to be omitted.
Therefore we need to find an alternative to the cursor value to determine if a response should contain a paging_metadata .

For XMLResponse the currently implemented behavior encodes the cursor as attribute of the <response> tag, regardless if the value is None. Clarification is necessary if this is according to specification.

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