diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index 85b411217..a0bdb5150 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -38,7 +38,6 @@ -type ip_port() :: tuple(). -type cipher() :: map(). -type rfc3339_system_time() :: integer(). --type unicode_binary() :: binary(). -typerefl_from_string({duration/0, emqx_schema, to_duration}). -typerefl_from_string({duration_s/0, emqx_schema, to_duration_s}). @@ -52,7 +51,6 @@ -typerefl_from_string({cipher/0, emqx_schema, to_erl_cipher_suite}). -typerefl_from_string({comma_separated_atoms/0, emqx_schema, to_comma_separated_atoms}). -typerefl_from_string({rfc3339_system_time/0, emqx_schema, rfc3339_to_system_time}). --typerefl_from_string({unicode_binary/0, emqx_schema, to_unicode_binary}). -export([ validate_heap_size/1 , parse_user_lookup_fun/1 @@ -66,8 +64,7 @@ to_bar_separated_list/1, to_ip_port/1, to_erl_cipher_suite/1, to_comma_separated_atoms/1, - rfc3339_to_system_time/1, - to_unicode_binary/1]). + rfc3339_to_system_time/1]). -behaviour(hocon_schema). @@ -76,8 +73,7 @@ comma_separated_list/0, bar_separated_list/0, ip_port/0, cipher/0, comma_separated_atoms/0, - rfc3339_system_time/0, - unicode_binary/0]). + rfc3339_system_time/0]). -export([namespace/0, roots/0, roots/1, fields/1]). -export([conf_get/2, conf_get/3, keys/2, filter/1]). @@ -1390,9 +1386,6 @@ rfc3339_to_system_time(DateTime) -> {error, bad_rfc3339_timestamp} end. -to_unicode_binary(Str) -> - {ok, unicode:characters_to_binary(Str)}. - to_bar_separated_list(Str) -> {ok, string:tokens(Str, "| ")}. diff --git a/apps/emqx_dashboard/src/emqx_dashboard_api.erl b/apps/emqx_dashboard/src/emqx_dashboard_api.erl index 45a3b7c56..ae2eb4e42 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_api.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_api.erl @@ -123,7 +123,7 @@ schema("/users/:username") -> #{in => path, example => <<"admin">>})}], 'requestBody' => [ { description - , mk(emqx_schema:unicode_binary(), + , mk(binary(), #{desc => <<"User description">>, example => <<"administrator">>})} ], responses => #{ @@ -176,7 +176,7 @@ schema("/users/:username/change_pwd") -> fields(user) -> [ {description, - mk(emqx_schema:unicode_binary(), + mk(binary(), #{desc => <<"User description">>, example => "administrator"})}, {username, mk(binary(), diff --git a/apps/emqx_management/src/emqx_mgmt_api_app.erl b/apps/emqx_management/src/emqx_mgmt_api_app.erl index b77f1a214..53ad01485 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_app.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_app.erl @@ -100,7 +100,7 @@ fields(app) -> #{desc => "ApiKey create datetime", example => <<"2021-12-01T00:00:00.000Z">> })}, - {desc, hoconsc:mk(emqx_schema:unicode_binary(), + {desc, hoconsc:mk(binary(), #{example => <<"Note">>, nullable => true})}, {enable, hoconsc:mk(boolean(), #{desc => "Enable/Disable", nullable => true})} ]; diff --git a/apps/emqx_management/src/emqx_mgmt_api_banned.erl b/apps/emqx_management/src/emqx_mgmt_api_banned.erl index 911b298a1..c6ff56ad0 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_banned.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_banned.erl @@ -101,15 +101,15 @@ fields(ban) -> desc => <<"Banned type clientid, username, peerhost">>, nullable => false, example => username})}, - {who, hoconsc:mk(emqx_schema:unicode_binary(), #{ + {who, hoconsc:mk(binary(), #{ desc => <<"Client info as banned type">>, nullable => false, example => <<"Badass坏"/utf8>>})}, - {by, hoconsc:mk(emqx_schema:unicode_binary(), #{ + {by, hoconsc:mk(binary(), #{ desc => <<"Commander">>, nullable => true, example => <<"mgmt_api">>})}, - {reason, hoconsc:mk(emqx_schema:unicode_binary(), #{ + {reason, hoconsc:mk(binary(), #{ desc => <<"Banned reason">>, nullable => true, example => <<"Too many requests">>})},