server: Correct pagination cursor calculation and limit default#526
Merged
Conversation
The next_cursor value returned by the _get_slice() method was not converted from 0-based indexing back to 1-based indexing. To fix this, a value of 1 is added to a returned cursor value. Fixes eclipse-basyx#520
The default value for the pagination limit in the method `_get_slice()` was set to 10. The [spec] specifies a different value of 100. This changes correct the implementation to be coherent with the spec. Fixes eclipse-basyx#521 [spec]: https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.1.2/http-rest-api/http-rest-api.html#pagination
Previously the cursor value for the paging_metadata of a paginated response was passed directly as `Optional[int]` to the constructor of `APIResponse`. The presence of the `cursor` attribute also controlled if the response contained a `paging_metadata`. This is not conform to the [spec] which requires the `paging_metadata` to be present in every paginated response. In case the response contains all remaining results, the `cursor` value inside must be omitted. This changes correct the behavior for `JSONResponse` to follow the [spec]. As the `PagingMetadata` might carry additional information in the future, a new class was used to pass all metadata from the `_get_slice(...)` method to the resulting `APIResponse`. For `XMLResponse` we mimic the previously implemented encoding of the `cursor` value. Fixes eclipse-basyx#519 [spec]: https://industrialdigitaltwin.io/aas-specifications/IDTA-01002/v3.1.2/http-rest-api/http-rest-api.html#pagination
zrgt
reviewed
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pagination implemented in
app.interfaces.base.BaseWSGIApp._get_slice(...)was not completely following the specification. This pull request bundles the changes that were made to correct the behavior.Changes
limitfor Pagination #521:The default value for the
limitquery parameter in a pagination request is set to100, as specified by AAS-Spec Part 2_get_slice(...)returns wrongcursorvalue #520_get_slice(...)now converts internal 0-basedcursorback to 1-based index, as it expects this as inputJsonResponsewith empty cursor #519:New
PagingMetadataclass is returned by_get_slice(...)and passed toAPIResponseinstead of rawcursorvalue. In aJSONResponsethis allows forpaging_metadatato be present, even if acursorvalue is absent, and is open for extension of the metadata in future. The encoding of thecursorvalue inXMLResponseis kept the same, as I was not able to find a schema for responses in XML format.For more details see the individual commit messages.