Skip to content

Commit

Permalink
Fix bug, isNullable is not being set from Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
cnizzardini committed Oct 2, 2024
1 parent 491ffec commit 3a3b191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Lib/Attribute/AbstractSchemaProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? []);
Expand Down
9 changes: 8 additions & 1 deletion tests/TestCase/Lib/Attribute/OpenApiSchemaPropertyTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace SwaggerBake\Test\TestCase\Lib\Attribute;

Expand All @@ -20,4 +21,10 @@ public function test_type_array(): void
$property = (new OpenApiSchemaProperty(name: 'test', type: 'array', items: ['type' => 'object']))->create();
$this->assertEquals(['type' => 'object'], $property->getItems());
}
}

public function test_is_nullable(): void
{
$property = (new OpenApiSchemaProperty(name: 'test', type: 'string', isNullable: true))->create();
$this->assertTrue($property->isNullable());
}
}

0 comments on commit 3a3b191

Please sign in to comment.