(t *testing.T)
| 172 | } |
| 173 | |
| 174 | func TestAPITool_CustomOutputSchema(t *testing.T) { |
| 175 | t.Parallel() |
| 176 | |
| 177 | customSchema := map[string]any{ |
| 178 | "type": "object", |
| 179 | "properties": map[string]any{ |
| 180 | "first_name": map[string]any{"type": "string"}, |
| 181 | "last_name": map[string]any{"type": "string"}, |
| 182 | "age": map[string]any{"type": "number"}, |
| 183 | }, |
| 184 | "required": []string{"first_name", "last_name"}, |
| 185 | } |
| 186 | |
| 187 | tool := New(latest.APIToolConfig{ |
| 188 | Name: "user-info", |
| 189 | Method: http.MethodGet, |
| 190 | Endpoint: "https://example.com/api/users/${id}", |
| 191 | Required: []string{"id"}, |
| 192 | Args: map[string]any{"id": map[string]any{"type": "number"}}, |
| 193 | OutputSchema: customSchema, |
| 194 | }, testExpander()) |
| 195 | |
| 196 | toolsList, err := tool.Tools(t.Context()) |
| 197 | require.NoError(t, err) |
| 198 | require.Len(t, toolsList, 1) |
| 199 | |
| 200 | schema, ok := toolsList[0].OutputSchema.(map[string]any) |
| 201 | require.True(t, ok) |
| 202 | assert.Equal(t, "object", schema["type"]) |
| 203 | |
| 204 | props, ok := schema["properties"].(map[string]any) |
| 205 | require.True(t, ok) |
| 206 | assert.Contains(t, props, "first_name") |
| 207 | assert.Contains(t, props, "age") |
| 208 | } |
| 209 | |
| 210 | func TestAPITool_RejectsLocalAddresses(t *testing.T) { |
| 211 | t.Parallel() |
nothing calls this directly
no test coverage detected