Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Support repeating query string params #36

Open
jdelight opened this issue May 9, 2017 · 3 comments
Open

Support repeating query string params #36

jdelight opened this issue May 9, 2017 · 3 comments

Comments

@jdelight
Copy link

jdelight commented May 9, 2017

Is it currently possible to build a request like:

http://my-app.com/?filter=1&filter=2&filter=3

In Django you can use request.query_params.getlist('filter') to return a list of [1,2,3]
However I'm not sure this is supported with the core api clients.

Seems to be because you can only have one filter property in the list of params:

if (field.location === 'query') {
    queryParams[field.name] = params[field.name];
    ...

The each filter is replaced with the next one.

@tomchristie
Copy link
Contributor

Howdy @jdelight! 😄

Rather than having multiple fields in this case, we want to have a single field, but allow the value of the parameter to be an array, and to handle the array case in the way you describe.

That's something that'll end up on my todo at some point, tho you're very welcome to take a crack at it first if you fancy.

@jdelight
Copy link
Author

jdelight commented May 9, 2017

That makes sense thanks @tomchristie. Will take a look if I can - but got a workaround for now. 😄
Which involves splitting the comma delimited string.

But yes, would be nice to figure out where the translation from array to query string param happens and if that's in coreapi or one of the URL helper libs.

@ryanolf
Copy link

ryanolf commented May 1, 2018

@tomchristie @jdelight I ran into the same issue of needing repeating parameters and have added this feature to my branch. See pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants