Commit 3c7586ae authored by Eric Durand-Tremblay's avatar Eric Durand-Tremblay
Browse files

Update samples and docs

1 merge request!10602Issue #10593 Fix nullable property implemented with oneOf construct
Pipeline #575 failed with stages
in 0 seconds
Showing with 531 additions and 48 deletions
+531 -48
6.0.1-SNAPSHOT
\ No newline at end of file
6.1.0-SNAPSHOT
\ No newline at end of file
......@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.openapitools.client.model.ModelNull;
import org.openapitools.client.model.ModelWithNullableObjectPropertyNonNullableProperty;
import org.openapitools.client.model.ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes;
import org.openapitools.client.model.PropertyType;
......
6.0.1-SNAPSHOT
\ No newline at end of file
6.1.0-SNAPSHOT
\ No newline at end of file
......@@ -14,4 +14,4 @@ class BigDecimalAdapter {
fun fromJson(value: String): BigDecimal {
return BigDecimal(value)
}
}
\ No newline at end of file
}
......@@ -14,4 +14,4 @@ class BigIntegerAdapter {
fun fromJson(value: String): BigInteger {
return BigInteger(value)
}
}
\ No newline at end of file
}
......@@ -22,7 +22,6 @@ package org.openapitools.client.models
import org.openapitools.client.models.ModelWithNullableObjectPropertyNonNullableProperty
import org.openapitools.client.models.ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes
import org.openapitools.client.models.Null
import org.openapitools.client.models.PropertyType
import com.squareup.moshi.Json
......
6.0.1-SNAPSHOT
\ No newline at end of file
6.1.0-SNAPSHOT
\ No newline at end of file
# OpenAPI\Client\DefaultApi
All URIs are relative to http://localhost.
All URIs are relative to http://localhost, except if the operation defines another base path.
Method | HTTP request | Description
------------- | ------------- | -------------
[**operation()**](DefaultApi.md#operation) | **GET** / |
| Method | HTTP request | Description |
| ------------- | ------------- | ------------- |
| [**operation()**](DefaultApi.md#operation) | **GET** / | |
## `operation()`
......
......@@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -359,10 +359,11 @@ class DefaultApi
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
......
......@@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......
......@@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -479,32 +479,31 @@ class Configuration
}
/**
* Returns URL based on the index and variables
*
* @param int $index index of the host settings
* @param array|null $variables hash of variable and the corresponding value (optional)
* @return string URL based on host settings
*/
public function getHostFromSettings($index, $variables = null)
* Returns URL based on host settings, index and variables
*
* @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients
* @param int $hostIndex index of the host settings
* @param array|null $variables hash of variable and the corresponding value (optional)
* @return string URL based on host settings
*/
public static function getHostString(array $hostsSettings, $hostIndex, array $variables = null)
{
if (null === $variables) {
$variables = [];
}
$hosts = $this->getHostSettings();
// check array index out of bound
if ($index < 0 || $index >= sizeof($hosts)) {
throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts));
if ($hostIndex < 0 || $hostIndex >= count($hostsSettings)) {
throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostsSettings));
}
$host = $hosts[$index];
$host = $hostsSettings[$hostIndex];
$url = $host["url"];
// go through variable and assign a value
foreach ($host["variables"] ?? [] as $name => $variable) {
if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user
if (in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
$url = str_replace("{".$name."}", $variables[$name], $url);
} else {
throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"]).".");
......@@ -517,4 +516,16 @@ class Configuration
return $url;
}
/**
* Returns URL based on the index and variables
*
* @param int $index index of the host settings
* @param array|null $variables hash of variable and the corresponding value (optional)
* @return string URL based on host settings
*/
public function getHostFromSettings($index, $variables = null)
{
return self::getHostString($this->getHostSettings(), $index, $variables);
}
}
......@@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -92,4 +92,20 @@ interface ModelInterface
* @return bool
*/
public function valid();
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool;
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool;
}
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -79,6 +79,26 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
'property_with_null_and_two_types' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'property_name' => false,
'property_name30' => true,
'property_name31' => true,
'non_nullable_property' => false,
'property_with_null_and_two_types' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
......@@ -99,6 +119,48 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
......@@ -196,11 +258,29 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
*/
public function __construct(array $data = null)
{
$this->container['property_name'] = $data['property_name'] ?? null;
$this->container['property_name30'] = $data['property_name30'] ?? null;
$this->container['property_name31'] = $data['property_name31'] ?? null;
$this->container['non_nullable_property'] = $data['non_nullable_property'] ?? null;
$this->container['property_with_null_and_two_types'] = $data['property_with_null_and_two_types'] ?? null;
$this->setIfExists('property_name', $data ?? [], null);
$this->setIfExists('property_name30', $data ?? [], null);
$this->setIfExists('property_name31', $data ?? [], null);
$this->setIfExists('non_nullable_property', $data ?? [], null);
$this->setIfExists('property_with_null_and_two_types', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
......@@ -246,6 +326,11 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
*/
public function setPropertyName($property_name)
{
if (is_null($property_name)) {
throw new \InvalidArgumentException('non-nullable property_name cannot be null');
}
$this->container['property_name'] = $property_name;
return $this;
......@@ -270,6 +355,18 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
*/
public function setPropertyName30($property_name30)
{
if (is_null($property_name30)) {
array_push($this->openAPINullablesSetToNull, 'property_name30');
} else {
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
$index = array_search('property_name30', $nullablesSetToNull);
if ($index !== FALSE) {
unset($nullablesSetToNull[$index]);
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
}
}
$this->container['property_name30'] = $property_name30;
return $this;
......@@ -294,6 +391,18 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
*/
public function setPropertyName31($property_name31)
{
if (is_null($property_name31)) {
array_push($this->openAPINullablesSetToNull, 'property_name31');
} else {
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
$index = array_search('property_name31', $nullablesSetToNull);
if ($index !== FALSE) {
unset($nullablesSetToNull[$index]);
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
}
}
$this->container['property_name31'] = $property_name31;
return $this;
......@@ -318,6 +427,11 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
*/
public function setNonNullableProperty($non_nullable_property)
{
if (is_null($non_nullable_property)) {
throw new \InvalidArgumentException('non-nullable non_nullable_property cannot be null');
}
$this->container['non_nullable_property'] = $non_nullable_property;
return $this;
......@@ -342,6 +456,11 @@ class ModelWithNullableObjectProperty implements ModelInterface, ArrayAccess, \J
*/
public function setPropertyWithNullAndTwoTypes($property_with_null_and_two_types)
{
if (is_null($property_with_null_and_two_types)) {
throw new \InvalidArgumentException('non-nullable property_with_null_and_two_types cannot be null');
}
$this->container['property_with_null_and_two_types'] = $property_with_null_and_two_types;
return $this;
......
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -71,6 +71,22 @@ class ModelWithNullableObjectPropertyNonNullableProperty implements ModelInterfa
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
......@@ -91,6 +107,48 @@ class ModelWithNullableObjectPropertyNonNullableProperty implements ModelInterfa
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
......@@ -178,6 +236,24 @@ class ModelWithNullableObjectPropertyNonNullableProperty implements ModelInterfa
{
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
......
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -73,6 +73,23 @@ class ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes implements Mode
'bar' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'foo' => false,
'bar' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
......@@ -93,6 +110,48 @@ class ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes implements Mode
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
......@@ -181,8 +240,26 @@ class ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes implements Mode
*/
public function __construct(array $data = null)
{
$this->container['foo'] = $data['foo'] ?? null;
$this->container['bar'] = $data['bar'] ?? null;
$this->setIfExists('foo', $data ?? [], null);
$this->setIfExists('bar', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
......@@ -228,6 +305,11 @@ class ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes implements Mode
*/
public function setFoo($foo)
{
if (is_null($foo)) {
throw new \InvalidArgumentException('non-nullable foo cannot be null');
}
$this->container['foo'] = $foo;
return $this;
......@@ -252,6 +334,11 @@ class ModelWithNullableObjectPropertyPropertyWithNullAndTwoTypes implements Mode
*/
public function setBar($bar)
{
if (is_null($bar)) {
throw new \InvalidArgumentException('non-nullable bar cannot be null');
}
$this->container['bar'] = $bar;
return $this;
......
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -71,6 +71,22 @@ class OtherPropertyType implements ModelInterface, ArrayAccess, \JsonSerializabl
'bar' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'bar' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
......@@ -91,6 +107,48 @@ class OtherPropertyType implements ModelInterface, ArrayAccess, \JsonSerializabl
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
......@@ -176,7 +234,25 @@ class OtherPropertyType implements ModelInterface, ArrayAccess, \JsonSerializabl
*/
public function __construct(array $data = null)
{
$this->container['bar'] = $data['bar'] ?? null;
$this->setIfExists('bar', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
......@@ -222,6 +298,11 @@ class OtherPropertyType implements ModelInterface, ArrayAccess, \JsonSerializabl
*/
public function setBar($bar)
{
if (is_null($bar)) {
throw new \InvalidArgumentException('non-nullable bar cannot be null');
}
$this->container['bar'] = $bar;
return $this;
......
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -71,6 +71,22 @@ class PropertyType implements ModelInterface, ArrayAccess, \JsonSerializable
'foo' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'foo' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
......@@ -91,6 +107,48 @@ class PropertyType implements ModelInterface, ArrayAccess, \JsonSerializable
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
......@@ -176,7 +234,25 @@ class PropertyType implements ModelInterface, ArrayAccess, \JsonSerializable
*/
public function __construct(array $data = null)
{
$this->container['foo'] = $data['foo'] ?? null;
$this->setIfExists('foo', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
......@@ -222,6 +298,11 @@ class PropertyType implements ModelInterface, ArrayAccess, \JsonSerializable
*/
public function setFoo($foo)
{
if (is_null($foo)) {
throw new \InvalidArgumentException('non-nullable foo cannot be null');
}
$this->container['foo'] = $foo;
return $this;
......
......@@ -17,7 +17,7 @@
*
* The version of the OpenAPI document: latest
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1-SNAPSHOT
* OpenAPI Generator version: 6.1.0-SNAPSHOT
*/
/**
......@@ -98,7 +98,7 @@ class ObjectSerializer
}
}
}
if ($value !== null) {
if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) {
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
}
}
......@@ -455,6 +455,11 @@ class ObjectSerializer
return $data;
} else {
$data = is_string($data) ? json_decode($data) : $data;
if (is_array($data)) {
$data = (object)$data;
}
// If a discriminator is defined and points to a valid subclass, use it.
$discriminator = $class::DISCRIMINATOR;
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
......@@ -469,7 +474,15 @@ class ObjectSerializer
foreach ($instance::openAPITypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
if (!isset($propertySetter)) {
continue;
}
if (!isset($data->{$instance::attributeMap()[$property]})) {
if ($instance::isNullable($property)) {
$instance->$propertySetter(null);
}
continue;
}
......
6.0.1-SNAPSHOT
\ No newline at end of file
6.1.0-SNAPSHOT
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment