fix(api): qos shcema & code formate

This commit is contained in:
DDDHuang 2022-02-09 17:05:06 +08:00
parent 471e867bf3
commit fbb8f46fcd
4 changed files with 11 additions and 13 deletions

View File

@ -38,7 +38,7 @@
-type ip_port() :: tuple().
-type cipher() :: map().
-type rfc3339_system_time() :: integer().
-type qos():: integer().
-type qos() :: integer().
-typerefl_from_string({qos/0, emqx_schema, to_qos}).
-typerefl_from_string({duration/0, emqx_schema, to_duration}).

View File

@ -92,12 +92,11 @@ stop_listeners() ->
%% internal
apps() ->
[emqx_management].
% [App || {App, _, _} <- application:loaded_applications(),
% case re:run(atom_to_list(App), "^emqx") of
% {match,[{0,4}]} -> true;
% _ -> false
% end].
[App || {App, _, _} <- application:loaded_applications(),
case re:run(atom_to_list(App), "^emqx") of
{match,[{0,4}]} -> true;
_ -> false
end].
listeners() ->
[begin

View File

@ -233,7 +233,7 @@ schema("/clients/:clientid/subscribe") ->
parameters => [{clientid, hoconsc:mk(binary(), #{in => path})}],
'requestBody' => hoconsc:mk(hoconsc:ref(?MODULE, subscribe)),
responses => #{
% 200 => hoconsc:ref(emqx_mgmt_api_subscriptions, subscription),
200 => hoconsc:ref(emqx_mgmt_api_subscriptions, subscription),
404 => emqx_dashboard_swagger:error_codes(
['CLIENTID_NOT_FOUND'], <<"Client id not found">>)
}
@ -369,7 +369,7 @@ fields(keepalive) ->
fields(subscribe) ->
[
{topic, hoconsc:mk(binary(), #{desc => <<"Access type">>})},
{qos, hoconsc:mk(integer(), #{desc => <<"Update time">>})}
{qos, hoconsc:mk(emqx_schema:qos(), #{desc => <<"QoS">>})}
];
fields(unsubscribe) ->

View File

@ -65,7 +65,7 @@ fields(subscription) ->
{node, hoconsc:mk(binary(), #{desc => <<"Access type">>})},
{topic, hoconsc:mk(binary(), #{desc => <<"Topic name">>})},
{clientid, hoconsc:mk(binary(), #{desc => <<"Client identifier">>})},
{qos, hoconsc:mk(hoconsc:enum([?QOS_0, ?QOS_1, ?QOS_2]), #{desc => <<"QoS">>})}
{qos, hoconsc:mk(emqx_schema:qos(), #{desc => <<"QoS">>})}
].
parameters() ->
@ -86,11 +86,10 @@ parameters() ->
desc => <<"Client ID">>})
},
{
qos, hoconsc:mk(hoconsc:union(
[typerefl:integer(0), typerefl:integer(1), typerefl:integer(2)]), #{
qos, hoconsc:mk(emqx_schema:qos(), #{
in => query,
nullable => true,
desc => "QoS"})
desc => <<"QoS">>})
},
{
topic, hoconsc:mk(binary(), #{