Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 30b7f92

Browse files
authored
fix: skip parameters with default as required in JsonSchema (#288)
1 parent bdddee6 commit 30b7f92

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Chain/JsonSchema/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function convertTypes(array $elements): ?array
9898

9999
if ($type->isNullable()) {
100100
$schema['type'] = [$schema['type'], 'null'];
101-
} else {
101+
} elseif (!($element instanceof \ReflectionParameter && $element->isOptional())) {
102102
$result['required'][] = $name;
103103
}
104104

tests/Chain/JsonSchema/FactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function buildParametersDefinitionOptional(): void
153153
'description' => 'A number given to the tool',
154154
],
155155
],
156-
'required' => ['text', 'number'],
156+
'required' => ['text'],
157157
'additionalProperties' => false,
158158
];
159159

tests/Chain/Toolbox/ToolboxTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function toolsMap(): void
100100
'description' => 'A number given to the tool',
101101
],
102102
],
103-
'required' => ['text', 'number'],
103+
'required' => ['text'],
104104
'additionalProperties' => false,
105105
],
106106
],
@@ -249,7 +249,7 @@ public function toolboxMapWithOverrideViaChain(): void
249249
'description' => 'A number given to the tool',
250250
],
251251
],
252-
'required' => ['text', 'number'],
252+
'required' => ['text'],
253253
'additionalProperties' => false,
254254
],
255255
],

0 commit comments

Comments
 (0)