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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] PHP Generator does not work with deepObject get params #11222

Closed
nadar opened this issue Jan 3, 2022 · 2 comments · Fixed by #11225
Closed

[BUG] PHP Generator does not work with deepObject get params #11222

nadar opened this issue Jan 3, 2022 · 2 comments · Fixed by #11225

Comments

@nadar
Copy link
Contributor

nadar commented Jan 3, 2022

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.

  1. Remove the use of Query::build and replace with http_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!

@nadar nadar changed the title [BUG] Description [BUG] PHP Generator does not work with deepObject get params Jan 3, 2022
@wing328
Copy link
Member

wing328 commented Jan 4, 2022

@nadar thanks for reporting the issue. Can you please file a PR to start with ?

@nadar
Copy link
Contributor Author

nadar commented Jan 4, 2022

There you go => #11225

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

Successfully merging a pull request may close this issue.

2 participants