verified-sources icon indicating copy to clipboard operation
verified-sources copied to clipboard

RESTAPI: Handle resolve params which return a list of elements

Open francescomucio opened this issue 1 year ago • 0 comments

Tell us what you do here

I modified the method that builds the path for resolve params

Short description

I introduced an internal method (to_list()) to convert the value returned by the parent resource to a Python list:

  • in case the parent resource returns a valid N-elements list, it is split into a N-element list
  • in case the parent resource returns a single value (or better something which is not a list), the value is put in a list with a single element.

Then process_parent_data_item() is returning not a single path but a list of paths, then paginate_dependent_resource needs to yield values from all the paths in the list.

Additional Context

This is a fairy common use case for APIs returning multiple elements from a search endpoint

francescomucio avatar May 30 '24 16:05 francescomucio