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 ip_port() :: tuple().
-type cipher() :: map(). -type cipher() :: map().
-type rfc3339_system_time() :: integer(). -type rfc3339_system_time() :: integer().
-type qos():: integer(). -type qos() :: integer().
-typerefl_from_string({qos/0, emqx_schema, to_qos}). -typerefl_from_string({qos/0, emqx_schema, to_qos}).
-typerefl_from_string({duration/0, emqx_schema, to_duration}). -typerefl_from_string({duration/0, emqx_schema, to_duration}).

View File

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

View File

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

View File

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