[BUG] PHP Generator does not work with deepObject get params
Created by: nadar
Description
The PHP SDK generator does not support deepObject
parameters. This is mainly because of \GuzzleHttp\Psr7\Query::build()
. When using a nested object build()
will return an PHP notice and the object will be added as ?filter=Array
instead of expected: ?filter[foo]=bar
PHP Notice: Array to string conversion in /vendor/guzzlehttp/psr7/src/Query.php on line 104
string(41) "?filter=Array"
openapi-generator version
latest dev-master
OpenAPI declaration file
An example which uses deepObject
- name: filter
in: query
description: Allows you to pass filtering options any attribute. `?filter[id]=123` or `?filter[author][like]=John`. Example of accessing nested array values `?filter[tags.alias]=food`
required: false
style: deepObject
explode: true
schema:
type: object
Suggest a fix
What is the reason to use \GuzzleHttp\Psr7\Query::build
? Because with php's http_build_query
the code would work.
- Remove the use of
Query::build
and replace withhttp_build_query
from php, see https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/php/api.mustache#L671
If this is an accepted solution, i would like to provide a PR, maybe this could be at least introduced as an option... If there is something i miss, or there is a possibility to correctly build get URLs with deep object, please let me know. (Maybe i can also help document how to use deepObject) with the PHP SDK Generator.
Thanks for all the amazing work!