forked from loafle/openapi-generator-original
Fix ObjectSerializer::isEmptyValue to not consider "0" as "" (#19472)
This commit is contained in:
parent
5b96e85fd5
commit
0643f526af
@ -188,6 +188,9 @@ class ObjectSerializer
|
||||
# For boolean values, '' is considered empty
|
||||
'bool','boolean' => !in_array($value, [false, 0], true),
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
'string' => $value === '',
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default => true
|
||||
};
|
||||
|
@ -185,6 +185,10 @@ class ObjectSerializer
|
||||
case 'boolean':
|
||||
return !in_array($value, [false, 0], true);
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
case 'string':
|
||||
return $value === '';
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default:
|
||||
return true;
|
||||
|
@ -198,6 +198,9 @@ class ObjectSerializer
|
||||
# For boolean values, '' is considered empty
|
||||
'bool','boolean' => !in_array($value, [false, 0], true),
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
'string' => $value === '',
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default => true
|
||||
};
|
||||
|
@ -198,6 +198,9 @@ class ObjectSerializer
|
||||
# For boolean values, '' is considered empty
|
||||
'bool','boolean' => !in_array($value, [false, 0], true),
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
'string' => $value === '',
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default => true
|
||||
};
|
||||
|
@ -197,6 +197,9 @@ class ObjectSerializer
|
||||
# For boolean values, '' is considered empty
|
||||
'bool','boolean' => !in_array($value, [false, 0], true),
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
'string' => $value === '',
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default => true
|
||||
};
|
||||
|
@ -194,6 +194,10 @@ class ObjectSerializer
|
||||
case 'boolean':
|
||||
return !in_array($value, [false, 0], true);
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
case 'string':
|
||||
return $value === '';
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default:
|
||||
return true;
|
||||
|
@ -430,6 +430,9 @@ class ObjectSerializerTest extends TestCase
|
||||
'form 0 bool, explode on, required false' => [
|
||||
0, 'field', 'bool', 'form', true, false, 'field=0',
|
||||
],
|
||||
'form string "0", explode on, required true' => [
|
||||
'0', 'field', 'string', 'form', true, true, 'field=0',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,10 @@ class ObjectSerializer
|
||||
case 'boolean':
|
||||
return !in_array($value, [false, 0], true);
|
||||
|
||||
# For string values, '' is considered empty.
|
||||
case 'string':
|
||||
return $value === '';
|
||||
|
||||
# For all the other types, any value at this point can be considered empty.
|
||||
default:
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user