Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds query string serialization optimization #312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akoenig
Copy link

@akoenig akoenig commented Apr 17, 2020

馃憢

This PR introduces the serialization of the query string, when the explode attribute has been set. When defined the actual serialization includes a duplication of the parameter. Otherwise arrays will be serialized in a comma-separated way.

Example with explode turned off:

http://localhost:3004/api/robots?types=Droid%2CBot

Example with explode turned on:

http://localhost:3004/api/robots?types=Droid&types=Bot

This also activates the useQuerystring mode in request so that the query string gets encoded properly (#308).

I ran into the "problem" today, when using query string parameters which are typed as arrays and wanted to help to fix that. So this is my PR 馃檪

@Alan-Cha
Copy link
Collaborator

@akoenig This is an awesome change!!! Thank you so much! We're in the middle of trying to get our 2.1.0 version out and I will try to get this in right after!

Respects the `explode` attribute. When defined the actual serialization includes a duplication of the parameter. Otherwise arrays will be serialized in a comma-separated way.

Signed-off-by: Andr茅 K枚nig <andre.koenig@openformation.io>
@Alan-Cha Alan-Cha force-pushed the feat/querystring-explosion branch from baf8677 to 7c2573c Compare May 12, 2020 13:26
Signed-off-by: Alan Cha <Alan.cha1@ibm.com>
@Alan-Cha Alan-Cha force-pushed the feat/querystring-explosion branch 2 times, most recently from 3bdaa3b to d462801 Compare May 13, 2020 06:26
@papatego
Copy link

papatego commented Jun 15, 2020

@Alan-Cha @akoenig how will this work when you have a nested object ?

> q = {filter: { first_name: 'hello', last_name: 'world'}}
{ filter: { first_name: 'hello', last_name: 'world' } }
> querystring.stringify(q)
'filter='

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

Successfully merging this pull request may close these issues.

None yet

3 participants