Просмотр исходного кода

chore(swagger-schema): Delete the schema that is not reused

Turtle 4 лет назад
Родитель
Сommit
675d23111c

+ 7 - 8
apps/emqx_dashboard/src/emqx_dashboard_api.erl

@@ -50,14 +50,13 @@
 -define(EMPTY(V), (V == undefined orelse V == <<>>)).
 
 api_spec() ->
-    {
-        [ login_api()
-        , logout_api()
-        , users_api()
-        , user_api()
-        , change_pwd_api()
-        ],
-        []}.
+    {[ login_api()
+     , logout_api()
+     , users_api()
+     , user_api()
+     , change_pwd_api()
+     ],
+    []}.
 
 login_api() ->
     AuthProps = properties([{username, string, <<"Username">>},

+ 7 - 8
apps/emqx_dashboard/src/emqx_dashboard_monitor_api.erl

@@ -26,14 +26,13 @@
                   , dropped]).
 
 api_spec() ->
-    {
-        [ monitor_api()
-        , monitor_nodes_api()
-        , monitor_nodes_counters_api()
-        , monitor_counters_api()
-        , monitor_current_api()],
-        []
-    }.
+    {[ monitor_api()
+     , monitor_nodes_api()
+     , monitor_nodes_counters_api()
+     , monitor_counters_api()
+     , monitor_current_api()
+    ],
+    []}.
 
 monitor_api() ->
     Metadata = #{

+ 1 - 4
apps/emqx_management/src/emqx_mgmt_api_routes.erl

@@ -36,10 +36,7 @@
                         ]).
 
 api_spec() ->
-    {
-        [routes_api(), route_api()],
-        []
-    }.
+    {[routes_api(), route_api()], []}.
 
 properties() ->
     properties([

+ 1 - 3
apps/emqx_management/src/emqx_mgmt_api_status.erl

@@ -29,9 +29,7 @@ status_api() ->
     Metadata = #{
         get => #{
             security => [],
-            responses => #{
-                <<"200">> => #{description => <<"running">>}
-            }
+            responses => #{<<"200">> => #{description => <<"running">>}}
         }
     },
     {Path, Metadata, running_status}.

+ 6 - 6
apps/emqx_modules/src/emqx_delayed_api.erl

@@ -49,11 +49,11 @@
 api_spec() ->
     {
         [status_api(), delayed_messages_api(), delayed_message_api()],
-        schemas()
+        []
     }.
 
-schemas() ->
-    [#{delayed => emqx_mgmt_api_configs:gen_schema(emqx:get_raw_config([delayed]))}].
+conf_schema() ->
+    emqx_mgmt_api_configs:gen_schema(emqx:get_raw_config([delayed])).
 properties() ->
     PayloadDesc = io_lib:format("Payload, base64 encode. Payload will be ~p if length large than ~p",
             [?PAYLOAD_TOO_LARGE, ?MAX_PAYLOAD_LENGTH]),
@@ -80,14 +80,14 @@ status_api() ->
         get => #{
             description => <<"Get delayed status">>,
             responses => #{
-                <<"200">> => schema(delayed)}
+                <<"200">> => schema(conf_schema())}
             },
         put => #{
             description => <<"Enable or disable delayed, set max delayed messages">>,
-            'requestBody' => schema(delayed),
+            'requestBody' => schema(conf_schema()),
             responses => #{
                 <<"200">> =>
-                    schema(delayed, <<"Enable or disable delayed successfully">>),
+                    schema(conf_schema(), <<"Enable or disable delayed successfully">>),
                 <<"400">> =>
                     error_schema(<<"Already disabled or enabled">>, [?ALREADY_ENABLED, ?ALREADY_DISABLED])
             }

+ 6 - 7
apps/emqx_modules/src/emqx_event_message_api.erl

@@ -25,11 +25,10 @@
                         ]).
 
 api_spec() ->
-    {[event_message_api()], [event_message_schema()]}.
+    {[event_message_api()], []}.
 
-event_message_schema() ->
-    Conf = emqx:get_raw_config([event_message]),
-    #{event_message => emqx_mgmt_api_configs:gen_schema(Conf)}.
+conf_schema() ->
+    emqx_mgmt_api_configs:gen_schema(emqx:get_config([event_message])).
 
 event_message_api() ->
     Path = "/mqtt/event_message",
@@ -37,14 +36,14 @@ event_message_api() ->
         get => #{
             description => <<"Event Message">>,
             responses => #{
-                <<"200">> => schema(event_message)
+                <<"200">> => schema(conf_schema())
             }
         },
         post => #{
             description => <<"Update Event Message">>,
-            'requestBody' => schema(event_message),
+            'requestBody' => schema(conf_schema()),
             responses => #{
-                <<"200">> => schema(event_message)
+                <<"200">> => schema(conf_schema())
             }
         }
     },

+ 6 - 6
apps/emqx_prometheus/src/emqx_prometheus_api.erl

@@ -29,21 +29,21 @@
         ]).
 
 api_spec() ->
-    {[prometheus_api(), prometheus_data_api()], schemas()}.
+    {[prometheus_api(), prometheus_data_api()], []}.
 
-schemas() ->
-    [#{prometheus => emqx_mgmt_api_configs:gen_schema(emqx:get_raw_config([prometheus]))}].
+conf_schema() ->
+    emqx_mgmt_api_configs:gen_schema(emqx:get_raw_config([prometheus])).
 
 prometheus_api() ->
     Metadata = #{
         get => #{
             description => <<"Get Prometheus info">>,
-            responses => #{<<"200">> => schema(prometheus)}
+            responses => #{<<"200">> => schema(conf_schema())}
         },
         put => #{
             description => <<"Update Prometheus">>,
-            'requestBody' => schema(prometheus),
-            responses => #{<<"200">> => schema(prometheus)}
+            'requestBody' => schema(conf_schema()),
+            responses => #{<<"200">> => schema(conf_schema())}
         }
     },
     {"/prometheus", Metadata, prometheus}.

+ 8 - 15
apps/emqx_retainer/src/emqx_retainer_api.erl

@@ -35,17 +35,10 @@
                         , properties/1]).
 
 api_spec() ->
-    {
-     [ lookup_retained_api()
-     , with_topic_api()
-     , config_api()
-     ],
-     schemas()
-    }.
-
-schemas() ->
-    MqttRetainer = gen_schema(emqx:get_raw_config([emqx_retainer])),
-    [#{emqx_retainer => MqttRetainer}].
+    {[lookup_retained_api(), with_topic_api(), config_api()], []}.
+
+conf_schema() ->
+    gen_schema(emqx:get_raw_config([emqx_retainer])).
 
 message_props() ->
     properties([
@@ -56,7 +49,7 @@ message_props() ->
         {publish_at, string, <<"publish datetime">>},
         {from_clientid, string, <<"publisher ClientId">>},
         {from_username, string, <<"publisher Username">>}
-        ]).
+    ]).
 
 parameters() ->
     [#{
@@ -107,15 +100,15 @@ config_api() ->
         get => #{
             description => <<"get retainer config">>,
             responses => #{
-                <<"200">> => schema(mqtt_retainer, <<"Get configs successfully">>),
+                <<"200">> => schema(conf_schema(), <<"Get configs successfully">>),
                 <<"404">> => error_schema(<<"Config not found">>, ['NOT_FOUND'])
             }
         },
         put => #{
             description => <<"Update retainer config">>,
-            'requestBody' => schema(mqtt_retainer),
+            'requestBody' => schema(conf_schema()),
             responses => #{
-                <<"200">> => schema(mqtt_retainer, <<"Update configs successfully">>),
+                <<"200">> => schema(conf_schema(), <<"Update configs successfully">>),
                 <<"400">> => error_schema(<<"Update configs failed">>, ['UPDATE_FAILED'])
             }
         }

+ 6 - 6
apps/emqx_statsd/src/emqx_statsd_api.erl

@@ -29,22 +29,22 @@
         ]).
 
 api_spec() ->
-    {statsd_api(), schemas()}.
+    {statsd_api(), []}.
 
-schemas() ->
-    [#{statsd => emqx_mgmt_api_configs:gen_schema(emqx:get_raw_config([statsd]))}].
+conf_schema() ->
+    emqx_mgmt_api_configs:gen_schema(emqx:get_raw_config([statsd])).
 
 statsd_api() ->
     Metadata = #{
         get => #{
             description => <<"Get statsd info">>,
-            responses => #{<<"200">> => schema(statsd)}
+            responses => #{<<"200">> => schema(conf_schema())}
         },
         put => #{
             description => <<"Update Statsd">>,
-            'requestBody' => schema(statsd),
+            'requestBody' => schema(conf_schema()),
             responses => #{
-                <<"200">> => schema(statsd),
+                <<"200">> => schema(conf_schema()),
                 <<"400">> => bad_request()
             }
         }