openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] PHP Client - ObjectSerializer::isEmptyValue consider "0" as ""

Open 50bhan opened this issue 1 year ago • 0 comments

Description

ObjectSerializer::isEmptyValue consider "0" as "" and instead of a zero wrapped in a string we're going to have an empty string which causes failure:

[422] Client error: `GET https://test.com/?foo=&bar=123` resulted in a `422 Unprocessable Entity` response:
OpenAPI declaration file content or url
paths:
  /internal/url:
    get:
      parameters:
        - name: foo
          required: true
          in: query
          schema:
            type: string

Results in generated PHP code from DefaultApi.php:

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $foo,
            'foo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
$queryParams = [
  'foo' => '',
]
Suggest a fix

I'm going to create a PR to fix this issue.

50bhan avatar Aug 28 '24 08:08 50bhan