fix: auto sub api doc & null body check (#5613)

* fix: auto sub api doc & null body check
This commit is contained in:
DDDHuang 2021-08-31 19:27:08 +08:00 committed by GitHub
parent 8d2b72c278
commit 560f415964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,7 @@
-export([auto_subscribe/2]).
-define(EXCEED_LIMIT, 'EXCEED_LIMIT').
-define(BAD_REQUEST, 'BAD_REQUEST').
api_spec() ->
{[auto_subscribe_api()], []}.
@ -43,6 +44,8 @@ auto_subscribe_api() ->
'requestBody' => schema(),
responses => #{
<<"200">> => schema(),
<<"400">> => emqx_mgmt_util:error_schema(
<<"Request body required">>, [?BAD_REQUEST]),
<<"409">> => emqx_mgmt_util:error_schema(
<<"Auto Subscribe topics max limit">>, [?EXCEED_LIMIT])}}
},
@ -53,6 +56,8 @@ auto_subscribe_api() ->
auto_subscribe(get, _) ->
{200, emqx_auto_subscribe:list()};
auto_subscribe(put, #{body := #{}}) ->
{400, #{code => ?BAD_REQUEST, message => <<"Request body required">>}};
auto_subscribe(put, #{body := Params}) ->
case emqx_auto_subscribe:update(Params) of
{error, quota_exceeded} ->