@@ -29,13 +29,22 @@ export const driverOptions = setupDriverConfig({
29
29
30
30
export const defaultDriverOptions : DriverOptions = { ...driverOptions } ;
31
31
32
- interface ParameterInfo {
32
+ interface Parameter {
33
33
name : string ;
34
- type : string ;
35
34
description : string ;
36
35
required : boolean ;
37
36
}
38
37
38
+ interface SingleValueParameter extends Parameter {
39
+ type : string ;
40
+ }
41
+
42
+ interface AnyOfParameter extends Parameter {
43
+ anyOf : { type : string } [ ] ;
44
+ }
45
+
46
+ type ParameterInfo = SingleValueParameter | AnyOfParameter ;
47
+
39
48
type ToolInfo = Awaited < ReturnType < Client [ "listTools" ] > > [ "tools" ] [ number ] ;
40
49
41
50
export interface IntegrationTest {
@@ -217,18 +226,38 @@ export function getParameters(tool: ToolInfo): ParameterInfo[] {
217
226
218
227
return Object . entries ( tool . inputSchema . properties )
219
228
. sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) )
220
- . map ( ( [ key , value ] ) => {
221
- expect ( value ) . toHaveProperty ( "type" ) ;
229
+ . map ( ( [ name , value ] ) => {
222
230
expect ( value ) . toHaveProperty ( "description" ) ;
223
231
224
- const typedValue = value as { type : string ; description : string } ;
225
- expect ( typeof typedValue . type ) . toBe ( "string" ) ;
226
- expect ( typeof typedValue . description ) . toBe ( "string" ) ;
232
+ const description = ( value as { description : string } ) . description ;
233
+ const required = ( tool . inputSchema . required as string [ ] ) ?. includes ( name ) ?? false ;
234
+ expect ( typeof description ) . toBe ( "string" ) ;
235
+
236
+ if ( value && typeof value === "object" && "anyOf" in value ) {
237
+ const typedOptions = new Array < { type : string } > ( ) ;
238
+ for ( const option of value . anyOf as { type : string } [ ] ) {
239
+ expect ( option ) . toHaveProperty ( "type" ) ;
240
+
241
+ typedOptions . push ( { type : option . type } ) ;
242
+ }
243
+
244
+ return {
245
+ name,
246
+ anyOf : typedOptions ,
247
+ description : description ,
248
+ required,
249
+ } ;
250
+ }
251
+
252
+ expect ( value ) . toHaveProperty ( "type" ) ;
253
+
254
+ const type = ( value as { type : string } ) . type ;
255
+ expect ( typeof type ) . toBe ( "string" ) ;
227
256
return {
228
- name : key ,
229
- type : typedValue . type ,
230
- description : typedValue . description ,
231
- required : ( tool . inputSchema . required as string [ ] ) ?. includes ( key ) ?? false ,
257
+ name,
258
+ type,
259
+ description,
260
+ required,
232
261
} ;
233
262
} ) ;
234
263
}
0 commit comments