Skip to content

Commit 524d10b

Browse files
author
marco.bernardi
committed
feat: change id value for map entity to be also nullable
1 parent 6704d55 commit 524d10b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/Model/EntityMapping.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class EntityMapping implements ModelInterface, ArrayAccess, \JsonSerializable
5858
* @var string[]
5959
*/
6060
protected static $openAPITypes = [
61-
'id' => 'string'
61+
'id' => 'string|null'
6262
];
6363

6464
/**
@@ -78,7 +78,7 @@ class EntityMapping implements ModelInterface, ArrayAccess, \JsonSerializable
7878
* @var boolean[]
7979
*/
8080
protected static array $openAPINullables = [
81-
'id' => false
81+
'id' => true
8282
];
8383

8484
/**
@@ -275,9 +275,6 @@ public function listInvalidProperties()
275275
{
276276
$invalidProperties = [];
277277

278-
if ($this->container['id'] === null) {
279-
$invalidProperties[] = "'id' can't be null";
280-
}
281278
return $invalidProperties;
282279
}
283280

@@ -310,10 +307,24 @@ public function getId()
310307
*
311308
* @return self
312309
*/
310+
/**
311+
* Sets id
312+
*
313+
* @param string|null $id id
314+
*
315+
* @return self
316+
*/
313317
public function setId($id)
314318
{
315319
if (is_null($id)) {
316-
throw new \InvalidArgumentException('non-nullable id cannot be null');
320+
array_push($this->openAPINullablesSetToNull, 'id');
321+
} else {
322+
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
323+
$index = array_search('id', $nullablesSetToNull);
324+
if ($index !== FALSE) {
325+
unset($nullablesSetToNull[$index]);
326+
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
327+
}
317328
}
318329
$this->container['id'] = $id;
319330

0 commit comments

Comments
 (0)