Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11222
Closed
Open
Issue created Jan 03, 2022 by Administrator@rootContributor

[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.

  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!

Assignee
Assign to
Time tracking