fix(banned): create banned with utf8 failed by 500
This commit is contained in:
parent
96ee51fe57
commit
b11a15fa00
|
@ -194,6 +194,7 @@ format(Traces) ->
|
|||
end, Traces).
|
||||
|
||||
init([]) ->
|
||||
ok = mria:wait_for_tables([?TRACE]),
|
||||
erlang:process_flag(trap_exit, true),
|
||||
OriginLogLevel = emqx_logger:get_primary_log_level(),
|
||||
ok = filelib:ensure_dir(trace_dir()),
|
||||
|
|
|
@ -211,11 +211,16 @@ check_request_body(#{body := Body}, Schema, Module, CheckFun, true) ->
|
|||
%% {good_nest_2, mk(ref(?MODULE, good_ref), #{})}
|
||||
%% ]}
|
||||
%% ]
|
||||
check_request_body(#{body := Body}, Spec, _Module, CheckFun, false) ->
|
||||
check_request_body(#{body := Body}, Spec, _Module, CheckFun, false)when is_list(Spec) ->
|
||||
lists:foldl(fun({Name, Type}, Acc) ->
|
||||
Schema = ?INIT_SCHEMA#{roots => [{Name, Type}]},
|
||||
maps:merge(Acc, CheckFun(Schema, Body, #{}))
|
||||
end, #{}, Spec).
|
||||
end, #{}, Spec);
|
||||
|
||||
%% requestBody => #{content => #{ 'application/octet-stream' =>
|
||||
%% #{schema => #{ type => string, format => binary}}}
|
||||
check_request_body(#{body := Body}, Spec, _Module, _CheckFun, false)when is_map(Spec) ->
|
||||
Body.
|
||||
|
||||
%% tags, description, summary, security, deprecated
|
||||
meta_to_spec(Meta, Module) ->
|
||||
|
@ -287,6 +292,7 @@ trans_desc(Spec, Hocon) ->
|
|||
Desc -> Spec#{description => to_bin(Desc)}
|
||||
end.
|
||||
|
||||
request_body(#{content := _} = Content, _Module) -> {Content, []};
|
||||
request_body([], _Module) -> {[], []};
|
||||
request_body(Schema, Module) ->
|
||||
{{Props, Refs}, Examples} =
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
-import(emqx_gateway_api_authn, [schema_authn/0]).
|
||||
|
||||
%% minirest/dashbaord_swagger behaviour callbacks
|
||||
%% minirest/dashboard_swagger behaviour callbacks
|
||||
-export([ api_spec/0
|
||||
, paths/0
|
||||
, schema/1
|
||||
|
|
|
@ -101,15 +101,15 @@ fields(ban) ->
|
|||
desc => <<"Banned type clientid, username, peerhost">>,
|
||||
nullable => false,
|
||||
example => username})},
|
||||
{who, hoconsc:mk(binary(), #{
|
||||
{who, hoconsc:mk(emqx_schema:unicode_binary(), #{
|
||||
desc => <<"Client info as banned type">>,
|
||||
nullable => false,
|
||||
example => <<"Badass">>})},
|
||||
example => <<"Badass坏"/utf8>>})},
|
||||
{by, hoconsc:mk(binary(), #{
|
||||
desc => <<"Commander">>,
|
||||
nullable => true,
|
||||
example => <<"mgmt_api">>})},
|
||||
{reason, hoconsc:mk(binary(), #{
|
||||
{reason, hoconsc:mk(emqx_schema:unicode_binary(), #{
|
||||
desc => <<"Banned reason">>,
|
||||
nullable => true,
|
||||
example => <<"Too many requests">>})},
|
||||
|
|
Loading…
Reference in New Issue