Skip to content

Commit 0b680f4

Browse files
committed
fix: JsonSchema required
1 parent 670fd6d commit 0b680f4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Chain/JsonSchema/Factory.php

+1-1
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

+1-1
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

+2-2
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)