From c3a6525328028e33a5c703724b9ac7803a4db8f1 Mon Sep 17 00:00:00 2001 From: Efe Bikmaz <50641281+bikmazefe@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:48:43 +0300 Subject: [PATCH] fix(PHP): Fix query param serialization of nested objects [TSI-2593] (#663) --- clients/php/test/Api/LocalesApiTest.php | 36 +++++++++++++++++++- openapi-generator/templates/php/api.mustache | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/clients/php/test/Api/LocalesApiTest.php b/clients/php/test/Api/LocalesApiTest.php index 151b71ed..fa62833b 100644 --- a/clients/php/test/Api/LocalesApiTest.php +++ b/clients/php/test/Api/LocalesApiTest.php @@ -134,7 +134,40 @@ public function testLocaleDownload() $projectId = "project_id_example"; $id = "locale_id"; - $result = $this->apiInstance->localeDownload($projectId, $id); + $file_format = "csv"; + $format_options = array( + "key" => "value", + "nested" => array( + "nested_key" => "nested_value" + ) + ); + $custom_metadata_filters = array('key' => 'value'); + + $result = $this->apiInstance-> localeDownload( + $projectId, + $id, + null, + null, + null, + null, + $file_format, + null, + null, + null, + null, + null, + null, + null, + $format_options, + null, + null, + null, + null, + null, + null, + $custom_metadata_filters + ); + $this->assertNotNull($result); $this->assertEquals('foo', $result); @@ -142,6 +175,7 @@ public function testLocaleDownload() $lastRequest = $this->history[count($this->history)-1]['request']; $this->assertEquals('GET', $lastRequest->getMethod()); $this->assertEquals('/v2/projects/'.$projectId.'/locales/'.$id.'/download', $lastRequest->getUri()->getPath()); + $this->assertEquals('file_format=csv&format_options%5Bkey%5D=value&format_options%5Bnested%5D%5Bnested_key%5D=nested_value&custom_metadata_filters%5Bkey%5D=value', $lastRequest->getUri()->getQuery()); } /** diff --git a/openapi-generator/templates/php/api.mustache b/openapi-generator/templates/php/api.mustache index 68e6e4c6..bb220148 100644 --- a/openapi-generator/templates/php/api.mustache +++ b/openapi-generator/templates/php/api.mustache @@ -637,7 +637,7 @@ use {{invokerPackage}}\ObjectSerializer; $operationHost = $operationHosts[$this->hostIndex]; {{/servers.0}} - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + $query = http_build_query($queryParams); return new Request( '{{httpMethod}}', {{^servers.0}}$this->config->getHost(){{/servers.0}}{{#servers.0}}$operationHost{{/servers.0}} . $resourcePath . ($query ? "?{$query}" : ''),