fix: response model with nullable defaults
This commit is contained in:
parent
bf9533007b
commit
641740db77
1 changed files with 1 additions and 1 deletions
|
@ -396,7 +396,7 @@ class Response extends SwooleResponse
|
||||||
|
|
||||||
foreach ($model->getRules() as $key => $rule) {
|
foreach ($model->getRules() as $key => $rule) {
|
||||||
if (!$document->isSet($key) && $rule['required']) { // do not set attribute in response if not required
|
if (!$document->isSet($key) && $rule['required']) { // do not set attribute in response if not required
|
||||||
if (!is_null($rule['default'])) {
|
if (\array_key_exists('default', $rule)) {
|
||||||
$document->setAttribute($key, $rule['default']);
|
$document->setAttribute($key, $rule['default']);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Model ' . $model->getName() . ' is missing response key: ' . $key);
|
throw new Exception('Model ' . $model->getName() . ' is missing response key: ' . $key);
|
||||||
|
|
Loading…
Reference in a new issue