-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] use http_build_query for deepObject support #11225
Conversation
Is there something i can improve to fix bitrise? |
For the bitrise CI failure, please ignore it. |
@nadar thanks for the PR. Can we add some tests in https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/php/OpenAPIClient-php/tests/ParametersTest.php ? |
Sure! |
@wing328 I have to admit i am not sure what kind of test you expect. As i have changed the default behavior in tests (i have modified all tests apis with the new code), if they are not failing there should be no BC break. I can add a very simple nested object tested for URLs, i will do that, but not sure if it helps, or makes anything more stable :-) but i'll do it. |
I'm taking care of it. Please don't merge or push anything. Gonna push commits soon. |
@ybelenko thanks for your help on this 👍 i have at least added a tests which shows that the default behavior is the same for query param generating. |
By the way, why don't we ask for deepObject support at Guzzle repo? |
Sure you can 👍 The be honest i have no idea what that function is made for, seems to be a sort of "ensure only scalar values are provided", but i assume there is a reason to have that function, otherwise they would just use |
@nadar thanks for adding the tests. It looks good from my side and happy to see this PR gets merged. |
Doesn't look good to me… |
@ybelenko i see, those data is generated diff checked, now i can more understand how the test works. |
I'm working on a fix which provide not only |
Also reverts 4 following commits. This reverts commit 5bfa396.
It looks a bit ugly right now, but at least all tests has been passed.
I used fixtures from OpenAPISpec main doc. Some prop combinations are not officially documented yet, for instance behavior for nested objects and arrays.
@nadar Please, check it out. I've added anonymous function to flatten query array so it solves Guzzle error. Should work with nested arrays now since all tests are passed. Also wrote small static function to wrap query build, we can migrate to openapi-generator/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php Lines 452 to 471 in 920cfe5
vendor/bin/phpunit tests/ObjectSerializerTest.php
PHPUnit 9.5.18
.................................................. 50 / 50 (100%)
Time: 00:00.059, Memory: 6.00 MB
OK (50 tests, 60 assertions) |
So you could fix the original issue without the |
I think so, at least minimal examples list works out of the box, including yours. I'm scared to test it with crazy fixtures(nested arrays of unexpected values) 😅 😅 😅 |
@nadar I'm pretty satisfied with the result here. I wait for your feedback, hope you can check it locally then I can merge. |
i will do a test tomorrow, but if my provided example works then i am totally happy!
should be evaluated as
|
It encodes deepObject that way above. |
Then, there is nothing to test for me. Amazing @ybelenko, thank you! |
Check locally anyway. We spent huge amount of time with this, might be huge disappointment if it doesn't work for you. |
@ybelenko very hard to test i have to admit. Or is there any good command how i could make the openapi generator fetch the data from that branch? openapi-generator-cli generate -i https://mysuperjson.json -g php --remote-generator=....... or can you give me a hint? |
@ybelenko i just copy the code quickly to my vendor files and adjust accordingly
And it works. 👍 Thanks |
great journey, thanks for the time @ybelenko |
Hey @ybelenko |
Looks like this broke some of the PHP petstore integration tests:
|
This fixes #11222
The Query::build() function does not support deepObjects in query params, but the OpenAPI defintion does.
I have replaced the
Query::build()
function with PHP's internal http_build_query function. I have adjust PHP default encoding to match the default encoding fromQuery::build()
which isPHP_QUERY_RFC3986
.This change will only have an effect for the query string of the URL, encoding POST bodys is still done by
Query::build()
.