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()); + } +}