Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug, isNullable is not being set from Attribute #559

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading