chore(mcp): satisfy revive lint rules
This commit is contained in:
parent
1ed894bee4
commit
e963d326ab
5 changed files with 16 additions and 5 deletions
|
|
@ -424,6 +424,8 @@ func TestBuildCuratedToolsUseStandardSchemaFormats(t *testing.T) {
|
||||||
for index, item := range typed {
|
for index, item := range typed {
|
||||||
collectFormats(t, tool, path+"/"+strconv.Itoa(index), item)
|
collectFormats(t, tool, path+"/"+strconv.Itoa(index), item)
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
// Scalars carry no nested schemas.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,8 @@ func normalizeSchemaFormat(schema map[string]any) {
|
||||||
case "bytes":
|
case "bytes":
|
||||||
delete(schema, "format")
|
delete(schema, "format")
|
||||||
schema["contentEncoding"] = "base64"
|
schema["contentEncoding"] = "base64"
|
||||||
|
default:
|
||||||
|
// Standard JSON Schema formats (date-time, int64, ...) pass through.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,13 +211,16 @@ func TestResolveSchemaRefNormalizesNonStandardFormats(t *testing.T) {
|
||||||
|
|
||||||
schema, err := resolveSchemaRef(spec, jsonSchema{"$ref": "#/components/schemas/Attachment"})
|
schema, err := resolveSchemaRef(spec, jsonSchema{"$ref": "#/components/schemas/Attachment"})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
properties := schema["properties"].(map[string]any)
|
properties, ok := schema["properties"].(map[string]any)
|
||||||
|
require.True(t, ok)
|
||||||
|
|
||||||
state := properties["state"].(map[string]any)
|
state, ok := properties["state"].(map[string]any)
|
||||||
|
require.True(t, ok)
|
||||||
require.NotContains(t, state, "format")
|
require.NotContains(t, state, "format")
|
||||||
require.Equal(t, []any{"NORMAL", "ARCHIVED"}, state["enum"])
|
require.Equal(t, []any{"NORMAL", "ARCHIVED"}, state["enum"])
|
||||||
|
|
||||||
content := properties["content"].(map[string]any)
|
content, ok := properties["content"].(map[string]any)
|
||||||
|
require.True(t, ok)
|
||||||
require.NotContains(t, content, "format")
|
require.NotContains(t, content, "format")
|
||||||
require.Equal(t, "base64", content["contentEncoding"])
|
require.Equal(t, "base64", content["contentEncoding"])
|
||||||
|
|
||||||
|
|
@ -229,7 +232,8 @@ func TestResolveSchemaRefNormalizesNonStandardFormats(t *testing.T) {
|
||||||
func TestSanitizeSchemaValueDoesNotMutateInput(t *testing.T) {
|
func TestSanitizeSchemaValueDoesNotMutateInput(t *testing.T) {
|
||||||
original := jsonSchema{"type": "string", "format": "enum", "items": map[string]any{"format": "bytes"}}
|
original := jsonSchema{"type": "string", "format": "enum", "items": map[string]any{"format": "bytes"}}
|
||||||
|
|
||||||
sanitized := sanitizeSchemaValue(original).(map[string]any)
|
sanitized, ok := sanitizeSchemaValue(original).(map[string]any)
|
||||||
|
require.True(t, ok)
|
||||||
require.NotContains(t, sanitized, "format")
|
require.NotContains(t, sanitized, "format")
|
||||||
require.Equal(t, "base64", sanitized["items"].(map[string]any)["contentEncoding"])
|
require.Equal(t, "base64", sanitized["items"].(map[string]any)["contentEncoding"])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ func catalogCacheMiddleware(next sdkmcp.MethodHandler) sdkmcp.MethodHandler {
|
||||||
typed.TTLMs = int(toolCatalogTTL.Milliseconds())
|
typed.TTLMs = int(toolCatalogTTL.Milliseconds())
|
||||||
case *sdkmcp.DiscoverResult:
|
case *sdkmcp.DiscoverResult:
|
||||||
typed.TTLMs = int(toolCatalogTTL.Milliseconds())
|
typed.TTLMs = int(toolCatalogTTL.Milliseconds())
|
||||||
|
default:
|
||||||
|
// Other results carry no catalog TTL.
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -568,7 +568,8 @@ func TestMCPRequestBodyLimitMatchesAPI(t *testing.T) {
|
||||||
echoServer.POST("/api/v1/attachments", func(c *echo.Context) error {
|
echoServer.POST("/api/v1/attachments", func(c *echo.Context) error {
|
||||||
body := map[string]any{}
|
body := map[string]any{}
|
||||||
require.NoError(t, json.NewDecoder(c.Request().Body).Decode(&body))
|
require.NoError(t, json.NewDecoder(c.Request().Body).Decode(&body))
|
||||||
content, _ := body["content"].(string)
|
content, ok := body["content"].(string)
|
||||||
|
require.True(t, ok)
|
||||||
receivedBytes = len(content)
|
receivedBytes = len(content)
|
||||||
return c.JSON(http.StatusOK, map[string]any{"name": "attachments/1"})
|
return c.JSON(http.StatusOK, map[string]any{"name": "attachments/1"})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue