-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[PHP] no need to serialize collections, Guzzle does that #3984
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,16 +472,24 @@ use {{invokerPackage}}\ObjectSerializer; | |
$multipart = false; | ||
|
||
{{#queryParams}} | ||
|
||
// query params | ||
{{#collectionFormat}} | ||
{{#isExplode}} | ||
if (${{paramName}} !== null) { | ||
$queryParams['{{baseName}}'] = ${{paramName}}; | ||
} | ||
{{/isExplode}} | ||
Comment on lines
+477
to
+481
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code doesn't properly support the 'form' style. If we look at other implementations (such as the Javascript one), when explode is true and style equals to 'form', the parameter should be expanded so that each key inside the parameter (which should then be an array) would result in a new query parameter. There is a very nice example of this in the accepted answer for this thread at stackoverflow.
The only problem here is: PR #4042 is unfortunately incomplete, and due to it, the style property is always empty. I've created a new PR #4640 to fix the issue... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EDIT: #4640 is merged now, which means the style property should work fine from now on! :) |
||
{{^isExplode}} | ||
if (is_array(${{paramName}})) { | ||
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}', true); | ||
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{#style}}{{style}}{{/style}}{{^style}}{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}{{/style}}', true); | ||
} | ||
{{/collectionFormat}} | ||
if (${{paramName}} !== null) { | ||
$queryParams['{{baseName}}'] = ObjectSerializer::toQueryValue(${{paramName}}); | ||
$queryParams['{{baseName}}'] = ${{paramName}}; | ||
} | ||
{{/isExplode}} | ||
|
||
{{/queryParams}} | ||
|
||
{{#headerParams}} | ||
// header params | ||
{{#collectionFormat}} | ||
|
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.
($collectionFormat doesn't exist anymore ;) )
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'll fix it in a separate PR.
If no further feedback, I'll merge it on the coming Tuesday.
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.
Filed #5517
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.
Thank you, William!
Do you want me to create a PR for my other comment (regarding "form" support)? I've been using the suggested fix in my own fork, and it works pretty fine! :)
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.
@thomasphansen yes please 👍
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.
Done! #5519