File tree Expand file tree Collapse file tree
.generator/src/generator/templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -350,9 +350,13 @@ class ApiClient:
350350 host=host,
351351 collection_formats=params["collection_format"],
352352 )
353- for item in get_attribute_from_path(response, pagination.get("results_path")):
353+ results = get_attribute_from_path(response, pagination.get("results_path"))
354+ for item in results:
354355 yield item
355- if len(get_attribute_from_path(response, pagination.get("results_path"))) < pagination["limit_value"]:
356+ if "cursor_param" in pagination:
357+ if len(results) == 0:
358+ break
359+ elif len(results) < pagination["limit_value"]:
356360 break
357361
358362 params = self._update_paginated_params(pagination, response)
@@ -651,9 +655,13 @@ class AsyncApiClient(ApiClient):
651655 host=host,
652656 collection_formats=params["collection_format"],
653657 )
654- for item in get_attribute_from_path(response, pagination.get("results_path")):
658+ results = get_attribute_from_path(response, pagination.get("results_path"))
659+ for item in results:
655660 yield item
656- if len(get_attribute_from_path(response, pagination.get("results_path"))) < pagination["limit_value"]:
661+ if "cursor_param" in pagination:
662+ if len(results) == 0:
663+ break
664+ elif len(results) < pagination["limit_value"]:
657665 break
658666
659667 params = self._update_paginated_params(pagination, response)
Original file line number Diff line number Diff line change @@ -357,9 +357,13 @@ def call_api_paginated(
357357 host = host ,
358358 collection_formats = params ["collection_format" ],
359359 )
360- for item in get_attribute_from_path (response , pagination .get ("results_path" )):
360+ results = get_attribute_from_path (response , pagination .get ("results_path" ))
361+ for item in results :
361362 yield item
362- if len (get_attribute_from_path (response , pagination .get ("results_path" ))) < pagination ["limit_value" ]:
363+ if "cursor_param" in pagination :
364+ if len (results ) == 0 :
365+ break
366+ elif len (results ) < pagination ["limit_value" ]:
363367 break
364368
365369 params = self ._update_paginated_params (pagination , response )
@@ -659,9 +663,13 @@ async def call_api_paginated(
659663 host = host ,
660664 collection_formats = params ["collection_format" ],
661665 )
662- for item in get_attribute_from_path (response , pagination .get ("results_path" )):
666+ results = get_attribute_from_path (response , pagination .get ("results_path" ))
667+ for item in results :
663668 yield item
664- if len (get_attribute_from_path (response , pagination .get ("results_path" ))) < pagination ["limit_value" ]:
669+ if "cursor_param" in pagination :
670+ if len (results ) == 0 :
671+ break
672+ elif len (results ) < pagination ["limit_value" ]:
665673 break
666674
667675 params = self ._update_paginated_params (pagination , response )
You can’t perform that action at this time.
0 commit comments