-
Notifications
You must be signed in to change notification settings - Fork 65
Fix comma separated list in query parameters #186
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #186 +/- ##
==========================================
- Coverage 87.89% 87.06% -0.83%
==========================================
Files 25 25
Lines 2593 2597 +4
==========================================
- Hits 2279 2261 -18
- Misses 314 336 +22
Continue to review full report at Codecov.
|
| for d | ||
| in data | ||
| ] | ||
| return str(self.serialize_iter(data, internal_data_type, **kwargs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we are not removing the capability to have separators other than ',' by calling serialize_iter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, never mind, I see we have tests for that. I would probably have called the parameter sep or separator rather than div. I was wondering what HTML had to do with this method when I first saw it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
legacy :)
| for d | ||
| in data | ||
| ] | ||
| return str(self.serialize_iter(data, internal_data_type, **kwargs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, never mind, I see we have tests for that. I would probably have called the parameter sep or separator rather than div. I was wondering what HTML had to do with this method when I first saw it :)
|
Did anyone happen to notice that while this passes tests and seems like an obvious fix, the resulting query parameter is encoded incorrectly? array/list query parameters are expected to be like this: z = new URLSearchParams()
URLSearchParams { }
z.append('friend', 'Robert Downey, Jr.')
undefined
z.append('friend', 'Michael Jordan')
undefined
z.getAll('friend')
Array [ "Robert Downey, Jr.", "Michael Jordan" ]
z.toString()
"friend=Robert+Downey%2C+Jr.&friend=Michael+Jordan"Additionally, note that putting a comma in the query string results in the same behavior as the encoded version: x = new URLSearchParams('friend=Robert+Downey,+Jr.&friend=Michael+Jordan')
URLSearchParams { }
x.getAll('friend')
Array [ "Robert Downey, Jr.", "Michael Jordan" ] |
|
A coworker pointed out that this may be relevant to the implementation of this feature: https://swagger.io/docs/specification/serialization/ (Or for 2.0 spec: https://swagger.io/docs/specification/2-0/describing-parameters/#array ) |
|
Looking closely, apparently 2.0 spec and 3.0 spec have different defaults, too. One is csv, the other is form, respectively. Fun times. |
Fix Azure/azure-sdk-for-python#6370