Skip to content

Commit

Permalink
fix(PHP): Fix query param serialization of nested objects [TSI-2593]
Browse files Browse the repository at this point in the history
  • Loading branch information
bikmazefe committed Jul 31, 2024
1 parent 2332d27 commit bcb9659
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
36 changes: 35 additions & 1 deletion clients/php/test/Api/LocalesApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,48 @@ 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);

$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());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion openapi-generator/templates/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}" : ''),
Expand Down

0 comments on commit bcb9659

Please sign in to comment.