Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328
2017-04-10 23:21:36 +08:00
9 changed files with 27 additions and 19 deletions

View File

@@ -62,7 +62,7 @@ class ObjectSerializer
foreach ($data::swaggerTypes() as $property => $swaggerType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
if (method_exists($swaggerType, 'getAllowableEnumValues')
if ($value !== null && method_exists($swaggerType, 'getAllowableEnumValues')
&& !in_array($value, $swaggerType::getAllowableEnumValues())) {
$imploded = implode("', '", $swaggerType::getAllowableEnumValues());
throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");