forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 6.0.x
This commit is contained in:
@@ -332,18 +332,15 @@ class ObjectSerializer
|
||||
}
|
||||
}
|
||||
|
||||
/** @psalm-suppress ParadoxicalCondition */
|
||||
if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
|
||||
settype($data, $class);
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ($class === '\SplFileObject') {
|
||||
/** @var \Psr\Http\Message\StreamInterface $data */
|
||||
|
||||
// determine file name
|
||||
if (array_key_exists('Content-Disposition', $httpHeaders) &&
|
||||
preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
|
||||
if (
|
||||
is_array($httpHeaders)
|
||||
&& array_key_exists('Content-Disposition', $httpHeaders)
|
||||
&& preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)
|
||||
) {
|
||||
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]);
|
||||
} else {
|
||||
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
|
||||
@@ -356,7 +353,16 @@ class ObjectSerializer
|
||||
fclose($file);
|
||||
|
||||
return new \SplFileObject($filename, 'r');
|
||||
} elseif (method_exists($class, 'getAllowableEnumValues')) {
|
||||
}
|
||||
|
||||
/** @psalm-suppress ParadoxicalCondition */
|
||||
if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
|
||||
settype($data, $class);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
if (method_exists($class, 'getAllowableEnumValues')) {
|
||||
if (!in_array($data, $class::getAllowableEnumValues(), true)) {
|
||||
$imploded = implode("', '", $class::getAllowableEnumValues());
|
||||
throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'");
|
||||
|
||||
Reference in New Issue
Block a user