[PHP] nullable attribute with value null gets removed
Created by: githubERIK
Description
Given a nullable field in OpenAPI object
SomeObject:
type: object
properties:
someProperty:
type: string
nullable: true
When HTTP Request has the object and it includes someProperty=null
.
Then the generated php client code does not include someProperty
in the response.
openapi-generator version
master branch (version 3.3.4) EDIT: also version 4.0.3
OpenAPI declaration file content or url
See the description
Command line used for generation
openapi-generator generate -g php
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
Remove null-check if-block if ($value !== null)
from https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache#L68
by changing this
if ($value !== null) {
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
}
to this
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);