Skip to main content

Optional Model Field Deserialization Issue

· One min read

There was an issue in code generation for PHP SDKs where the model classes (custom types) had fields with incorrect PHP typehints. This lead to the JsonMapper mapping responses incorrectly to models during deserialization. However, this only occurred when a model had fields that were described as optional in the API description and no default value was provided.

Re-generate your PHP SDK to get the fix.

Details

In cases where model fields were optional, the PHP typehints being added did not allow for a null value. For example, an optional integer value should have a integer|null typehint but was incorrectly given just integer. This caused the JsonMapper to incorrectly initialize the field to a non-zero value, like 0, when the response did not contain the field or the field was null. This fix will allow null to be correctly mapped on to the field.

This issue was specific to code generation for PHP SDKs.