Преглед изворни кода

fix(api): qos shcema & code formate

DDDHuang пре 4 година
родитељ
комит
fbb8f46fcd

+ 1 - 1
apps/emqx/src/emqx_schema.erl

@@ -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}).

+ 5 - 6
apps/emqx_dashboard/src/emqx_dashboard.erl

@@ -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

+ 2 - 2
apps/emqx_management/src/emqx_mgmt_api_clients.erl

@@ -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) ->

+ 3 - 4
apps/emqx_management/src/emqx_mgmt_api_subscriptions.erl

@@ -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(), #{