Improved code by updating any interfaces
Change-Id: I9a2e630c37f3c427569f5bbd773978c2705dc08c
diff --git a/tools/schema_test.go b/tools/schema_test.go
index 4365537..240d0c1 100644
--- a/tools/schema_test.go
+++ b/tools/schema_test.go
@@ -37,14 +37,14 @@
}
// validateBasicSchemaStructure checks that the schema has the required top-level properties
-func validateBasicSchemaStructure(t *testing.T, schema map[string]interface{}, toolName string) {
+func validateBasicSchemaStructure(t *testing.T, schema map[string]any, toolName string) {
// Must be object type
assert.Equal(t, "object", schema["type"], "Tool %s schema must be object type", toolName)
// Must have properties
properties, exists := schema["properties"]
assert.True(t, exists, "Tool %s schema must have properties", toolName)
- assert.IsType(t, map[string]interface{}{}, properties, "Tool %s properties must be an object", toolName)
+ assert.IsType(t, map[string]any{}, properties, "Tool %s properties must be an object", toolName)
// Must have required array
required, exists := schema["required"]
@@ -61,11 +61,11 @@
}
// validateSchemaIsValidJSON ensures the schema can be properly serialized to JSON
-func validateSchemaIsValidJSON(t *testing.T, schema map[string]interface{}, toolName string) {
+func validateSchemaIsValidJSON(t *testing.T, schema map[string]any, toolName string) {
jsonBytes, err := json.Marshal(schema)
require.NoError(t, err, "Tool %s schema must be serializable to JSON", toolName)
- var unmarshalled map[string]interface{}
+ var unmarshalled map[string]any
err = json.Unmarshal(jsonBytes, &unmarshalled)
require.NoError(t, err, "Tool %s schema JSON must be valid", toolName)
@@ -74,12 +74,12 @@
}
// validateSchemaDocumentation checks that all properties have proper documentation
-func validateSchemaDocumentation(t *testing.T, schema map[string]interface{}, toolName string) {
- properties, ok := schema["properties"].(map[string]interface{})
+func validateSchemaDocumentation(t *testing.T, schema map[string]any, toolName string) {
+ properties, ok := schema["properties"].(map[string]any)
require.True(t, ok, "Tool %s properties must be accessible", toolName)
for propName, propSchema := range properties {
- propMap, ok := propSchema.(map[string]interface{})
+ propMap, ok := propSchema.(map[string]any)
require.True(t, ok, "Tool %s property %s must be an object", toolName, propName)
// Must have type
@@ -133,10 +133,10 @@
tool := NewSearchTool(client)
schema := tool.InputSchema()
- properties := schema["properties"].(map[string]interface{})
+ properties := schema["properties"].(map[string]any)
// Test query examples
- queryProp := properties["query"].(map[string]interface{})
+ queryProp := properties["query"].(map[string]any)
examples := queryProp["examples"].([]string)
for _, example := range examples {
@@ -145,7 +145,7 @@
}
// Test corpus examples
- corpusProp := properties["corpus"].(map[string]interface{})
+ corpusProp := properties["corpus"].(map[string]any)
corpusExamples := corpusProp["examples"].([]string)
for _, example := range corpusExamples {
@@ -160,10 +160,10 @@
tool := NewMetadataTool(client)
schema := tool.InputSchema()
- properties := schema["properties"].(map[string]interface{})
+ properties := schema["properties"].(map[string]any)
// Test action examples
- actionProp := properties["action"].(map[string]interface{})
+ actionProp := properties["action"].(map[string]any)
examples := actionProp["examples"].([]string)
enumValues := actionProp["enum"].([]string)
@@ -180,10 +180,10 @@
t.Run("SearchTool", func(t *testing.T) {
tool := NewSearchTool(client)
schema := tool.InputSchema()
- properties := schema["properties"].(map[string]interface{})
+ properties := schema["properties"].(map[string]any)
// Test query constraints
- queryProp := properties["query"].(map[string]interface{})
+ queryProp := properties["query"].(map[string]any)
minLength := queryProp["minLength"].(int)
maxLength := queryProp["maxLength"].(int)
@@ -192,7 +192,7 @@
assert.LessOrEqual(t, maxLength, 10000, "Query maximum length should be reasonable")
// Test count constraints
- countProp := properties["count"].(map[string]interface{})
+ countProp := properties["count"].(map[string]any)
minimum := countProp["minimum"].(int)
maximum := countProp["maximum"].(int)
defaultValue := countProp["default"].(int)
@@ -228,14 +228,14 @@
// Tool-specific stability checks
switch tool.Name() {
case "korap_search":
- properties := schema["properties"].(map[string]interface{})
+ properties := schema["properties"].(map[string]any)
assert.Contains(t, properties, "query", "Search tool must always have query parameter")
required := schema["required"].([]string)
assert.Contains(t, required, "query", "Search tool must always require query parameter")
case "korap_metadata":
- properties := schema["properties"].(map[string]interface{})
+ properties := schema["properties"].(map[string]any)
assert.Contains(t, properties, "action", "Metadata tool must always have action parameter")
required := schema["required"].([]string)
@@ -312,14 +312,14 @@
}
// generateHelpText creates human-readable help text from a schema
-func generateHelpText(schema map[string]interface{}, toolName string) string {
+func generateHelpText(schema map[string]any, toolName string) string {
help := fmt.Sprintf("Tool: %s\n", toolName)
if desc, ok := schema["description"].(string); ok {
help += fmt.Sprintf("Description: %s\n\n", desc)
}
- properties, ok := schema["properties"].(map[string]interface{})
+ properties, ok := schema["properties"].(map[string]any)
if !ok {
return help
}
@@ -332,7 +332,7 @@
help += "Parameters:\n"
for paramName, paramSchema := range properties {
- paramMap, ok := paramSchema.(map[string]interface{})
+ paramMap, ok := paramSchema.(map[string]any)
if !ok {
continue
}