@@ -296,13 +296,26 @@ static List<String> getFunctionParametersList(Map<String, Object> paramsMap) {
296
296
} else if (value instanceof Boolean ) {
297
297
functionParametersList .add (String .format ("%s: %s" , key , value ));
298
298
} else if (value instanceof List ) {
299
- if (!(( List ) value ). isEmpty () && !((( List ) value ). get ( 0 ) instanceof String )) {
300
- throw new CodegenException ( "Plugin function parameters not supported for type List<"
301
- + (( List ) value ). get ( 0 ). getClass () + " >" );
299
+ List <?> valueList = ( List <?> ) value ;
300
+ if (! valueList . isEmpty () && !( valueList . get ( 0 ) instanceof String )) {
301
+ throw new CodegenException ( "Plugin function parameters list must be List<String >" );
302
302
}
303
- functionParametersList .add (String .format ("%s: [%s]" ,
304
- key , ((List <String >) value ).stream ()
305
- .collect (Collectors .joining ("\" , \" " , "\" " , "\" " ))));
303
+ List <String > valueStringList = valueList .stream ()
304
+ .map (item -> String .format ("'%s'" , item ))
305
+ .collect (Collectors .toList ());
306
+ functionParametersList .add (String .format ("'%s': [%s]" ,
307
+ key , valueStringList .stream ().collect (Collectors .joining (", " ))));
308
+ } else if (value instanceof Map ) {
309
+ Map <?, ?> valueMap = (Map <?, ?>) value ;
310
+ if (!valueMap .isEmpty () && valueMap .keySet ().stream ().anyMatch (k -> !(k instanceof String ))
311
+ && valueMap .values ().stream ().anyMatch (v -> !(v instanceof String ))) {
312
+ throw new CodegenException ("Plugin function parameters map must be Map<String, String>" );
313
+ }
314
+ List <String > valueStringList = valueMap .entrySet ().stream ()
315
+ .map (entry -> String .format ("'%s': '%s'" , entry .getKey (), entry .getValue ()))
316
+ .collect (Collectors .toList ());
317
+ functionParametersList .add (String .format ("%s: {%s}" ,
318
+ key , valueStringList .stream ().collect (Collectors .joining (", " ))));
306
319
} else {
307
320
// Future support for param type should be added in else if.
308
321
throw new CodegenException ("Plugin function parameters not supported for type "
0 commit comments