chore(schema): remove emqx_schema:unicode_binary/0

This commit is contained in:
zhongwencool 2021-12-28 23:50:12 +08:00
parent 47be5b9ef2
commit 0712fc1e75
4 changed files with 8 additions and 15 deletions

View File

@ -38,7 +38,6 @@
-type ip_port() :: tuple(). -type ip_port() :: tuple().
-type cipher() :: map(). -type cipher() :: map().
-type rfc3339_system_time() :: integer(). -type rfc3339_system_time() :: integer().
-type unicode_binary() :: binary().
-typerefl_from_string({duration/0, emqx_schema, to_duration}). -typerefl_from_string({duration/0, emqx_schema, to_duration}).
-typerefl_from_string({duration_s/0, emqx_schema, to_duration_s}). -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({cipher/0, emqx_schema, to_erl_cipher_suite}).
-typerefl_from_string({comma_separated_atoms/0, emqx_schema, to_comma_separated_atoms}). -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({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 -export([ validate_heap_size/1
, parse_user_lookup_fun/1 , parse_user_lookup_fun/1
@ -66,8 +64,7 @@
to_bar_separated_list/1, to_ip_port/1, to_bar_separated_list/1, to_ip_port/1,
to_erl_cipher_suite/1, to_erl_cipher_suite/1,
to_comma_separated_atoms/1, to_comma_separated_atoms/1,
rfc3339_to_system_time/1, rfc3339_to_system_time/1]).
to_unicode_binary/1]).
-behaviour(hocon_schema). -behaviour(hocon_schema).
@ -76,8 +73,7 @@
comma_separated_list/0, bar_separated_list/0, ip_port/0, comma_separated_list/0, bar_separated_list/0, ip_port/0,
cipher/0, cipher/0,
comma_separated_atoms/0, comma_separated_atoms/0,
rfc3339_system_time/0, rfc3339_system_time/0]).
unicode_binary/0]).
-export([namespace/0, roots/0, roots/1, fields/1]). -export([namespace/0, roots/0, roots/1, fields/1]).
-export([conf_get/2, conf_get/3, keys/2, filter/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} {error, bad_rfc3339_timestamp}
end. end.
to_unicode_binary(Str) ->
{ok, unicode:characters_to_binary(Str)}.
to_bar_separated_list(Str) -> to_bar_separated_list(Str) ->
{ok, string:tokens(Str, "| ")}. {ok, string:tokens(Str, "| ")}.

View File

@ -123,7 +123,7 @@ schema("/users/:username") ->
#{in => path, example => <<"admin">>})}], #{in => path, example => <<"admin">>})}],
'requestBody' => [ 'requestBody' => [
{ description { description
, mk(emqx_schema:unicode_binary(), , mk(binary(),
#{desc => <<"User description">>, example => <<"administrator">>})} #{desc => <<"User description">>, example => <<"administrator">>})}
], ],
responses => #{ responses => #{
@ -176,7 +176,7 @@ schema("/users/:username/change_pwd") ->
fields(user) -> fields(user) ->
[ [
{description, {description,
mk(emqx_schema:unicode_binary(), mk(binary(),
#{desc => <<"User description">>, example => "administrator"})}, #{desc => <<"User description">>, example => "administrator"})},
{username, {username,
mk(binary(), mk(binary(),

View File

@ -100,7 +100,7 @@ fields(app) ->
#{desc => "ApiKey create datetime", #{desc => "ApiKey create datetime",
example => <<"2021-12-01T00:00:00.000Z">> example => <<"2021-12-01T00:00:00.000Z">>
})}, })},
{desc, hoconsc:mk(emqx_schema:unicode_binary(), {desc, hoconsc:mk(binary(),
#{example => <<"Note">>, nullable => true})}, #{example => <<"Note">>, nullable => true})},
{enable, hoconsc:mk(boolean(), #{desc => "Enable/Disable", nullable => true})} {enable, hoconsc:mk(boolean(), #{desc => "Enable/Disable", nullable => true})}
]; ];

View File

@ -101,15 +101,15 @@ fields(ban) ->
desc => <<"Banned type clientid, username, peerhost">>, desc => <<"Banned type clientid, username, peerhost">>,
nullable => false, nullable => false,
example => username})}, example => username})},
{who, hoconsc:mk(emqx_schema:unicode_binary(), #{ {who, hoconsc:mk(binary(), #{
desc => <<"Client info as banned type">>, desc => <<"Client info as banned type">>,
nullable => false, nullable => false,
example => <<"Badass坏"/utf8>>})}, example => <<"Badass坏"/utf8>>})},
{by, hoconsc:mk(emqx_schema:unicode_binary(), #{ {by, hoconsc:mk(binary(), #{
desc => <<"Commander">>, desc => <<"Commander">>,
nullable => true, nullable => true,
example => <<"mgmt_api">>})}, example => <<"mgmt_api">>})},
{reason, hoconsc:mk(emqx_schema:unicode_binary(), #{ {reason, hoconsc:mk(binary(), #{
desc => <<"Banned reason">>, desc => <<"Banned reason">>,
nullable => true, nullable => true,
example => <<"Too many requests">>})}, example => <<"Too many requests">>})},