diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl index 1e7e44a33..ac122b5dc 100644 --- a/src/mod_http_api.erl +++ b/src/mod_http_api.erl @@ -332,6 +332,14 @@ format_arg({Elements}, ({Val}) when is_list(Val) -> format_arg({Val}, Tuple) end, Elements); +format_arg(Map, + {list, {_ElementDefName, {tuple, [{_Tuple1N, Tuple1S}, {_Tuple2N, Tuple2S}]}}}) + when is_map(Map) andalso + (Tuple1S == binary orelse Tuple1S == string) -> + maps:fold( + fun(K, V, Acc) -> + [{format_arg(K, Tuple1S), format_arg(V, Tuple2S)} | Acc] + end, [], Map); format_arg(Elements, {list, {_ElementDefName, {list, _} = ElementDefFormat}}) when is_list(Elements) -> diff --git a/test/commands_tests.erl b/test/commands_tests.erl index 4081a9e07..9cc23dee5 100644 --- a/test/commands_tests.erl +++ b/test/commands_tests.erl @@ -47,7 +47,8 @@ single_cases() -> single_test(http_restuple), single_test(http_list), single_test(http_tuple), - single_test(http_list_tuple)]}. + single_test(http_list_tuple), + single_test(http_list_tuple_map)]}. setup(_Config) -> M = <<"mod_example">>, @@ -139,6 +140,13 @@ http_list_tuple(Config) -> ?match(LTB, query(Config, "command_test_list_tuple", #{arg_list => LTA})), ?match(LTB, query(Config, "command_test_list_tuple", #{arg_list => LTB})). +http_list_tuple_map(Config) -> + LTA = #{<<"one">> => <<"uno">>, <<"dos">> => <<"two">>, <<"three">> => <<"tres">>}, + LTB = lists:sort([#{<<"element1">> => <<"one">>, <<"element2">> => <<"uno">>}, + #{<<"element1">> => <<"dos">>, <<"element2">> => <<"two">>}, + #{<<"element1">> => <<"three">>, <<"element2">> => <<"tres">>}]), + ?match(LTB, lists:sort(query(Config, "command_test_list_tuple", #{arg_list => LTA}))). + %%%================================== %%%% internal functions