refactor: apply review requests

This commit is contained in:
Thales Macedo Garitezi 2024-06-17 10:31:49 -03:00
parent 9b3c806ba7
commit ec4f462684
2 changed files with 13 additions and 13 deletions

View File

@ -155,11 +155,11 @@ schema("/message_transformations/dryrun") ->
post => #{ post => #{
tags => ?TAGS, tags => ?TAGS,
summary => <<"Test an input against a configuration">>, summary => <<"Test an input against a configuration">>,
description => ?DESC("test_transformation"), description => ?DESC("dryrun_transformation"),
'requestBody' => 'requestBody' =>
emqx_dashboard_swagger:schema_with_examples( emqx_dashboard_swagger:schema_with_examples(
ref(test_transformation), ref(dryrun_transformation),
example_input_test_transformation() example_input_dryrun_transformation()
), ),
responses => responses =>
#{ #{
@ -292,27 +292,27 @@ fields(reorder) ->
[ [
{order, mk(array(binary()), #{required => true, in => body})} {order, mk(array(binary()), #{required => true, in => body})}
]; ];
fields(test_transformation) -> fields(dryrun_transformation) ->
[ [
{transformation, {transformation,
mk( mk(
hoconsc:ref(emqx_message_transformation_schema, transformation), hoconsc:ref(emqx_message_transformation_schema, transformation),
#{required => true, in => body} #{required => true, in => body}
)}, )},
{message, mk(ref(test_input_message), #{required => true, in => body})} {message, mk(ref(dryrun_input_message), #{required => true, in => body})}
]; ];
fields(test_input_message) -> fields(dryrun_input_message) ->
%% See `emqx_message_transformation:eval_context()'. %% See `emqx_message_transformation:eval_context()'.
[ [
{client_attrs, mk(map(), #{required => true})}, {client_attrs, mk(map(), #{default => #{}})},
{payload, mk(binary(), #{required => true})}, {payload, mk(binary(), #{required => true})},
{qos, mk(range(0, 2), #{required => true})}, {qos, mk(range(0, 2), #{default => 0})},
{retain, mk(boolean(), #{required => true})}, {retain, mk(boolean(), #{default => false})},
{topic, mk(binary(), #{required => true})}, {topic, mk(binary(), #{required => true})},
{user_property, {user_property,
mk( mk(
typerefl:alias("map(binary(), binary())", user_property()), typerefl:alias("map(binary(), binary())", user_property()),
#{required => true} #{default => #{}}
)} )}
]; ];
fields(get_metrics) -> fields(get_metrics) ->
@ -487,7 +487,7 @@ example_input_reorder() ->
} }
}. }.
example_input_test_transformation() -> example_input_dryrun_transformation() ->
#{ #{
<<"test">> => <<"test">> =>
#{ #{
@ -736,7 +736,7 @@ dryrun_input_message_in(Params) ->
%% expect it to succeed here. %% expect it to succeed here.
#{root := Result = #{message := Message0}} = #{root := Result = #{message := Message0}} =
hocon_tconf:check_plain( hocon_tconf:check_plain(
#{roots => [{root, ref(test_transformation)}]}, #{roots => [{root, ref(dryrun_transformation)}]},
#{<<"root">> => Params}, #{<<"root">> => Params},
#{atom_key => true} #{atom_key => true}
), ),

View File

@ -18,7 +18,7 @@ emqx_message_transformation_http_api {
reorder_transformations.desc: reorder_transformations.desc:
"""Reorder of all transformations""" """Reorder of all transformations"""
test_transformation.desc: dryrun_transformation.desc:
"""Test an input against a transformation""" """Test an input against a transformation"""
enable_disable_transformation.desc: enable_disable_transformation.desc: