Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
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
5 changes: 5 additions & 0 deletions src/Chain/StructuredOutput/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public function buildSchema(string $className): array
$type = $types[0];
$propertySchema = $this->getTypeSchema($type);

// Handle nullable types
if (!is_array($propertySchema['type']) && $type->isNullable()) {
$propertySchema['type'] = [$propertySchema['type'], 'null'];
}

// Add description if available
if ($description) {
$propertySchema['description'] = $description;
Expand Down
1 change: 1 addition & 0 deletions tests/Chain/StructuredOutput/ResponseFormatFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function create(): void
'format' => 'date-time',
],
'isActive' => ['type' => 'boolean'],
'age' => ['type' => ['integer', 'null']],
],
'required' => ['id', 'name', 'createdAt', 'isActive'],
'additionalProperties' => false,
Expand Down
1 change: 1 addition & 0 deletions tests/Chain/StructuredOutput/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function buildSchemaForUserClass(): void
'format' => 'date-time',
],
'isActive' => ['type' => 'boolean'],
'age' => ['type' => ['integer', 'null']],
],
'required' => ['id', 'name', 'createdAt', 'isActive'],
'additionalProperties' => false,
Expand Down
1 change: 1 addition & 0 deletions tests/Fixture/StructuredOutput/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ final class User
public string $name;
public \DateTimeInterface $createdAt;
public bool $isActive;
public ?int $age = null;
}
Loading