Skip to content

Commit ab1c282

Browse files
committed
adapt cursor from 0-indexed to 1-indexed
1 parent da671d3 commit ab1c282

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sdk/basyx/aas/adapter/http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,13 @@ def _get_submodel_reference(cls, aas: model.AssetAdministrationShell, submodel_i
654654
@classmethod
655655
def _get_slice(cls, request: Request, iterator: Iterable[T]) -> Tuple[Iterator[T], int]:
656656
limit_str = request.args.get('limit', default="10")
657-
cursor_str = request.args.get('cursor', default="0")
657+
cursor_str = request.args.get('cursor', default="1")
658658
try:
659-
limit, cursor = int(limit_str), int(cursor_str)
659+
limit, cursor = int(limit_str), int(cursor_str) - 1 # cursor is 1-indexed
660660
if limit < 0 or cursor < 0:
661661
raise ValueError
662662
except ValueError:
663-
raise BadRequest("Cursor and limit must be positive integers!")
663+
raise BadRequest("Limit can not be negative, cursor must be positive!")
664664
start_index = cursor
665665
end_index = cursor + limit
666666
paginated_slice = itertools.islice(iterator, start_index, end_index)

0 commit comments

Comments
 (0)