@@ -55,23 +55,23 @@ class ObjectSerializer
55
55
if (is_object($data)) {
56
56
$values = [];
57
57
if ($data instanceof ModelInterface) {
58
- $formats = $data ::openAPIFormats ();
59
- foreach ($data ::openAPITypes () as $property => $openAPIType ) {
58
+ $formats = $data ::modelFormats ();
59
+ foreach ($data ::modelTypes () as $property => $modelTypes ) {
60
60
$getter = $data ::getters()[$property ];
61
61
$value = $data -> $getter ();
62
- if ($value !== null && ! in_array($openAPIType , [{{{primitives} }}], true)) {
63
- $callable = [$openAPIType , ' getAllowableEnumValues' ];
62
+ if ($value !== null && ! in_array($modelTypes , [{{{primitives} }}], true)) {
63
+ $callable = [$modelTypes , ' getAllowableEnumValues' ];
64
64
if (is_callable($callable )) {
65
65
/** array $callable */
66
66
$allowedEnumTypes = $callable ();
67
67
if (! in_array($value , $allowedEnumTypes , true )) {
68
68
$imploded = implode(" ', '" , $allowedEnumTypes );
69
- throw new \InvalidArgumentException(" Invalid value for enum '$openAPIType ', must be one of: '$imploded'" );
69
+ throw new \InvalidArgumentException(" Invalid value for enum '$modelTypes ', must be one of: '$imploded'" );
70
70
}
71
71
}
72
72
}
73
73
if ($value !== null) {
74
- $values [$data ::attributeMap()[$property ]] = self::sanitizeForSerialization($value , $openAPIType , $formats [$property ]);
74
+ $values [$data ::attributeMap()[$property ]] = self::sanitizeForSerialization($value , $modelTypes , $formats [$property ]);
75
75
}
76
76
}
77
77
} else {
@@ -319,18 +319,10 @@ class ObjectSerializer
319
319
return $data;
320
320
} else {
321
321
$data = is_string($data ) ? json_decode($data ) : $data ;
322
- // If a discriminator is defined and points to a valid subclass, use it.
323
- $discriminator = $class ::DISCRIMINATOR;
324
- if (! empty($discriminator ) && isset($data -> {$discriminator } ) && is_string($data->{ $discriminator } )) {
325
- $subclass = ' \{ {invokerPackage}}\M odel\\ ' . $data -> {$discriminator } ;
326
- if (is_subclass_of($subclass, $class)) {
327
- $class = $subclass ;
328
- }
329
- }
330
322
331
323
/** @var ModelInterface $instance */
332
324
$instance = new $class ();
333
- foreach ($instance::openAPITypes () as $property => $type) {
325
+ foreach ($instance ::modelTypes () as $property => $type ) {
334
326
$propertySetter = $instance ::setters()[$property ];
335
327
336
328
if (! isset($propertySetter ) || ! isset($data -> {$instance ::attributeMap()[$property ]} )) {
0 commit comments