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

refactor: delete stale type converters

Some of the types are refactored to use typerefl alias
or hoconsc:enum, no need to keep the special function
clauses to translate them to swagger spec
Zaiming (Stone) Shi 2 лет назад
Родитель
Сommit
b7d2c38213
2 измененных файлов с 2 добавлено и 44 удалено
  1. 2 22
      apps/emqx_conf/src/emqx_conf.erl
  2. 0 22
      apps/emqx_dashboard/src/emqx_dashboard_swagger.erl

+ 2 - 22
apps/emqx_conf/src/emqx_conf.erl

@@ -355,34 +355,14 @@ typename_to_spec("comma_separated_list()", _Mod) ->
     #{type => comma_separated_string};
 typename_to_spec("comma_separated_atoms()", _Mod) ->
     #{type => comma_separated_string};
-typename_to_spec("pool_type()", _Mod) ->
-    #{type => enum, symbols => [random, hash]};
-typename_to_spec("log_level()", _Mod) ->
-    #{
-        type => enum,
-        symbols => [
-            debug,
-            info,
-            notice,
-            warning,
-            error,
-            critical,
-            alert,
-            emergency,
-            all
-        ]
-    };
-typename_to_spec("rate()", _Mod) ->
-    #{type => string};
 typename_to_spec("capacity()", _Mod) ->
     #{type => string};
-typename_to_spec("burst_rate()", _Mod) ->
-    #{type => string};
 typename_to_spec("failure_strategy()", _Mod) ->
     #{type => enum, symbols => [force, drop, throw]};
 typename_to_spec("initial()", _Mod) ->
     #{type => string};
-typename_to_spec("map()", _Mod) ->
+typename_to_spec("map(" ++ Map, _Mod) ->
+    [$) | _MapArgs] = lists:reverse(Map),
     #{type => object};
 typename_to_spec("#{" ++ _, Mod) ->
     typename_to_spec("map()", Mod);

+ 0 - 22
apps/emqx_dashboard/src/emqx_dashboard_swagger.erl

@@ -799,8 +799,6 @@ hocon_schema_to_spec(?UNION(Types, _DisplayName), LocalModule) ->
 hocon_schema_to_spec(Atom, _LocalModule) when is_atom(Atom) ->
     {#{type => string, enum => [Atom]}, []}.
 
-typename_to_spec("term()", _Mod) ->
-    #{type => string, example => <<"any">>};
 typename_to_spec("boolean()", _Mod) ->
     #{type => boolean};
 typename_to_spec("binary()", _Mod) ->
@@ -884,26 +882,6 @@ typename_to_spec("comma_separated_binary()", _Mod) ->
     #{type => string, example => <<"item1,item2">>};
 typename_to_spec("comma_separated_atoms()", _Mod) ->
     #{type => string, example => <<"item1,item2">>};
-typename_to_spec("pool_type()", _Mod) ->
-    #{type => string, enum => [random, hash]};
-typename_to_spec("log_level()", _Mod) ->
-    #{
-        type => string,
-        enum => [debug, info, notice, warning, error, critical, alert, emergency, all]
-    };
-typename_to_spec("rate()", _Mod) ->
-    #{type => string, example => <<"10MB">>};
-typename_to_spec("burst()", _Mod) ->
-    #{type => string, example => <<"100MB">>};
-typename_to_spec("burst_rate()", _Mod) ->
-    %% 0/0s = no burst
-    #{type => string, example => <<"10MB">>};
-typename_to_spec("failure_strategy()", _Mod) ->
-    #{type => string, example => <<"force">>};
-typename_to_spec("initial()", _Mod) ->
-    #{type => string, example => <<"0MB">>};
-typename_to_spec("bucket_name()", _Mod) ->
-    #{type => string, example => <<"retainer">>};
 typename_to_spec("json_binary()", _Mod) ->
     #{type => string, example => <<"{\"a\": [1,true]}">>};
 typename_to_spec("port_number()", _Mod) ->