Skip to content

Commit ca5e1e7

Browse files
authored
Merge pull request #55 from trandbert37/feature/add-all-supported-tool-types
Add all supported tool types
2 parents 950183a + ee39e6c commit ca5e1e7

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

src/Command/MigrateToolSchemaCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ private function mapJsonSchemaTypeToPropertyType(string $jsonType): string
169169
return match ($jsonType) {
170170
'string' => 'STRING',
171171
'integer' => 'INTEGER',
172+
'array' => 'ARRAY',
173+
'boolean' => 'BOOLEAN',
174+
'object' => 'OBJECT',
175+
'number' => 'NUMBER',
172176
default => 'STRING', // Fallback for unsupported types
173177
};
174178
}

src/Services/ToolService/Schema/PropertyType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ enum PropertyType
66
{
77
case STRING;
88
case INTEGER;
9+
case NUMBER;
10+
case OBJECT;
11+
case ARRAY;
12+
case BOOLEAN;
913
}

src/Services/ToolService/Schema/StructuredSchema.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ private function getPropertyType(SchemaProperty $property): string
7777
return match ($property->getType()) {
7878
PropertyType::STRING => 'string',
7979
PropertyType::INTEGER => 'integer',
80+
PropertyType::ARRAY => 'array',
81+
PropertyType::BOOLEAN => 'boolean',
82+
PropertyType::OBJECT => 'object',
83+
PropertyType::NUMBER => 'number',
8084
};
8185
}
8286
}

src/Services/ToolService/ToolParamsValidator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private static function validateType(string $expectedType, mixed $actualValue):
105105
'boolean' => is_bool($actualValue),
106106
'array' => is_array($actualValue),
107107
'object' => is_object($actualValue),
108+
'number' => is_numeric($actualValue),
108109
default => false
109110
};
110111
}

tests/Command/MigrateToolSchemaCommandTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ public function test_map_json_schema_type_to_property_type(): void
198198

199199
$this->assertEquals('STRING', $method->invoke($command, 'string'));
200200
$this->assertEquals('INTEGER', $method->invoke($command, 'integer'));
201+
$this->assertEquals('ARRAY', $method->invoke($command, 'array'));
202+
$this->assertEquals('BOOLEAN', $method->invoke($command, 'boolean'));
203+
$this->assertEquals('OBJECT', $method->invoke($command, 'object'));
204+
$this->assertEquals('NUMBER', $method->invoke($command, 'number'));
201205
$this->assertEquals('STRING', $method->invoke($command, 'unknown')); // Fallback
202-
$this->assertEquals('STRING', $method->invoke($command, 'boolean')); // Fallback
203206
}
204207

205208
public function test_generate_use_statements_with_existing_statements(): void

tests/Services/ToolService/Schema/PropertyTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PropertyTypeTest extends TestCase
1212
public function test_enum_cases_exist(): void
1313
{
1414
$this->assertIsArray(PropertyType::cases());
15-
$this->assertCount(2, PropertyType::cases());
15+
$this->assertCount(6, PropertyType::cases());
1616
}
1717

1818
public function test_string_case_exists(): void
@@ -29,7 +29,7 @@ public function test_integer_case_exists(): void
2929

3030
public function test_all_cases_have_correct_names(): void
3131
{
32-
$expectedCases = ['STRING', 'INTEGER'];
32+
$expectedCases = ['STRING', 'INTEGER', 'NUMBER', 'OBJECT', 'ARRAY', 'BOOLEAN'];
3333
$actualCases = array_map(fn ($case) => $case->name, PropertyType::cases());
3434

3535
$this->assertEquals($expectedCases, $actualCases);
@@ -38,7 +38,7 @@ public function test_all_cases_have_correct_names(): void
3838
public function test_enum_values_are_unique(): void
3939
{
4040
$cases = PropertyType::cases();
41-
$this->assertCount(2, $cases);
41+
$this->assertCount(6, $cases);
4242
$this->assertNotEquals($cases[0], $cases[1]);
4343
}
4444

0 commit comments

Comments
 (0)