fix: auto sub api doc & null body check (#5613)
* fix: auto sub api doc & null body check
This commit is contained in:
parent
8d2b72c278
commit
560f415964
|
@ -23,6 +23,7 @@
|
||||||
-export([auto_subscribe/2]).
|
-export([auto_subscribe/2]).
|
||||||
|
|
||||||
-define(EXCEED_LIMIT, 'EXCEED_LIMIT').
|
-define(EXCEED_LIMIT, 'EXCEED_LIMIT').
|
||||||
|
-define(BAD_REQUEST, 'BAD_REQUEST').
|
||||||
|
|
||||||
api_spec() ->
|
api_spec() ->
|
||||||
{[auto_subscribe_api()], []}.
|
{[auto_subscribe_api()], []}.
|
||||||
|
@ -43,6 +44,8 @@ auto_subscribe_api() ->
|
||||||
'requestBody' => schema(),
|
'requestBody' => schema(),
|
||||||
responses => #{
|
responses => #{
|
||||||
<<"200">> => schema(),
|
<<"200">> => schema(),
|
||||||
|
<<"400">> => emqx_mgmt_util:error_schema(
|
||||||
|
<<"Request body required">>, [?BAD_REQUEST]),
|
||||||
<<"409">> => emqx_mgmt_util:error_schema(
|
<<"409">> => emqx_mgmt_util:error_schema(
|
||||||
<<"Auto Subscribe topics max limit">>, [?EXCEED_LIMIT])}}
|
<<"Auto Subscribe topics max limit">>, [?EXCEED_LIMIT])}}
|
||||||
},
|
},
|
||||||
|
@ -53,6 +56,8 @@ auto_subscribe_api() ->
|
||||||
auto_subscribe(get, _) ->
|
auto_subscribe(get, _) ->
|
||||||
{200, emqx_auto_subscribe:list()};
|
{200, emqx_auto_subscribe:list()};
|
||||||
|
|
||||||
|
auto_subscribe(put, #{body := #{}}) ->
|
||||||
|
{400, #{code => ?BAD_REQUEST, message => <<"Request body required">>}};
|
||||||
auto_subscribe(put, #{body := Params}) ->
|
auto_subscribe(put, #{body := Params}) ->
|
||||||
case emqx_auto_subscribe:update(Params) of
|
case emqx_auto_subscribe:update(Params) of
|
||||||
{error, quota_exceeded} ->
|
{error, quota_exceeded} ->
|
||||||
|
|
Loading…
Reference in New Issue