Skip to content

Commit 204ffc0

Browse files
authored
Merge pull request #58 from trandbert37/feature/use-backed-enum-for-property-type
Use backed enum for property types
2 parents 73553ef + 7632fa2 commit 204ffc0

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/Services/ToolService/Schema/PropertyType.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace KLP\KlpMcpServer\Services\ToolService\Schema;
44

5-
enum PropertyType
5+
enum PropertyType: string
66
{
7-
case STRING;
8-
case INTEGER;
9-
case NUMBER;
10-
case OBJECT;
11-
case ARRAY;
12-
case BOOLEAN;
7+
case STRING = 'string';
8+
case INTEGER = 'integer';
9+
case NUMBER = 'number';
10+
case OBJECT = 'object';
11+
case ARRAY = 'array';
12+
case BOOLEAN = 'boolean';
1313
}

src/Services/ToolService/Schema/StructuredSchema.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function asArray(): array
5656

5757
foreach ($this->properties as $property) {
5858
$propertySchema = [
59-
'type' => $this->getPropertyType($property),
59+
'type' => $property->getType()->value,
6060
'description' => $property->getDescription(),
6161
];
6262

@@ -98,16 +98,4 @@ public function asArray(): array
9898
'required' => $required,
9999
];
100100
}
101-
102-
private function getPropertyType(SchemaProperty $property): string
103-
{
104-
return match ($property->getType()) {
105-
PropertyType::STRING => 'string',
106-
PropertyType::INTEGER => 'integer',
107-
PropertyType::ARRAY => 'array',
108-
PropertyType::BOOLEAN => 'boolean',
109-
PropertyType::OBJECT => 'object',
110-
PropertyType::NUMBER => 'number',
111-
};
112-
}
113101
}

0 commit comments

Comments
 (0)