From da2c4745cb8fea8cdea1b35916f99728b23dd390 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Tue, 1 Oct 2024 22:07:50 -0400 Subject: [PATCH] Fix bug, isNullable is not being set from Attribute --- src/Lib/Attribute/AbstractSchemaProperty.php | 3 ++- .../TestCase/Lib/Attribute/OpenApiSchemaPropertyTest.php | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Lib/Attribute/AbstractSchemaProperty.php b/src/Lib/Attribute/AbstractSchemaProperty.php index 5f849af3..84b82752 100644 --- a/src/Lib/Attribute/AbstractSchemaProperty.php +++ b/src/Lib/Attribute/AbstractSchemaProperty.php @@ -91,7 +91,8 @@ public function create(): SchemaProperty ->setReadOnly($this->isReadOnly) ->setWriteOnly($this->isWriteOnly) ->setRequired($this->isRequired) - ->setEnum($this->enum ?? []); + ->setEnum($this->enum ?? []) + ->setNullable($this->isNullable); if ($schemaProperty->getType() === 'array') { $schemaProperty->setItems($this->items ?? []); diff --git a/tests/TestCase/Lib/Attribute/OpenApiSchemaPropertyTest.php b/tests/TestCase/Lib/Attribute/OpenApiSchemaPropertyTest.php index d0be2e10..4009aadf 100644 --- a/tests/TestCase/Lib/Attribute/OpenApiSchemaPropertyTest.php +++ b/tests/TestCase/Lib/Attribute/OpenApiSchemaPropertyTest.php @@ -1,4 +1,5 @@ 'object']))->create(); $this->assertEquals(['type' => 'object'], $property->getItems()); } -} \ No newline at end of file + + public function test_is_nullable(): void + { + $property = (new OpenApiSchemaProperty(name: 'test', type: 'string', isNullable: true))->create(); + $this->assertTrue($property->isNullable()); + } +}