refactor: delete default type converter for dashboard schema json
prior to this commit, dashboard scheam json type conversion has a 'fallback' type for all unknown types, which is 'string' this commit removes this fallback and add all possible types to the function clauses. also, some of the old types which are no longer in use are deleted from both swagger spec converter and dashboard sechema converter
This commit is contained in:
parent
b7d2c38213
commit
2fda91ec59
|
@ -305,10 +305,6 @@ hocon_schema_to_spec(?UNION(Types, _DisplayName), LocalModule) ->
|
||||||
hocon_schema_to_spec(Atom, _LocalModule) when is_atom(Atom) ->
|
hocon_schema_to_spec(Atom, _LocalModule) when is_atom(Atom) ->
|
||||||
{#{type => enum, symbols => [Atom]}, []}.
|
{#{type => enum, symbols => [Atom]}, []}.
|
||||||
|
|
||||||
typename_to_spec("user_id_type()", _Mod) ->
|
|
||||||
#{type => enum, symbols => [clientid, username]};
|
|
||||||
typename_to_spec("term()", _Mod) ->
|
|
||||||
#{type => string};
|
|
||||||
typename_to_spec("boolean()", _Mod) ->
|
typename_to_spec("boolean()", _Mod) ->
|
||||||
#{type => boolean};
|
#{type => boolean};
|
||||||
typename_to_spec("binary()", _Mod) ->
|
typename_to_spec("binary()", _Mod) ->
|
||||||
|
@ -317,6 +313,8 @@ typename_to_spec("float()", _Mod) ->
|
||||||
#{type => number};
|
#{type => number};
|
||||||
typename_to_spec("integer()", _Mod) ->
|
typename_to_spec("integer()", _Mod) ->
|
||||||
#{type => number};
|
#{type => number};
|
||||||
|
typename_to_spec("pos_integer()", _Mod) ->
|
||||||
|
#{type => integer};
|
||||||
typename_to_spec("non_neg_integer()", _Mod) ->
|
typename_to_spec("non_neg_integer()", _Mod) ->
|
||||||
#{type => number, minimum => 0};
|
#{type => number, minimum => 0};
|
||||||
typename_to_spec("number()", _Mod) ->
|
typename_to_spec("number()", _Mod) ->
|
||||||
|
@ -355,26 +353,22 @@ typename_to_spec("comma_separated_list()", _Mod) ->
|
||||||
#{type => comma_separated_string};
|
#{type => comma_separated_string};
|
||||||
typename_to_spec("comma_separated_atoms()", _Mod) ->
|
typename_to_spec("comma_separated_atoms()", _Mod) ->
|
||||||
#{type => comma_separated_string};
|
#{type => comma_separated_string};
|
||||||
typename_to_spec("capacity()", _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(" ++ Map, _Mod) ->
|
typename_to_spec("map(" ++ Map, _Mod) ->
|
||||||
[$) | _MapArgs] = lists:reverse(Map),
|
[$) | _MapArgs] = lists:reverse(Map),
|
||||||
#{type => object};
|
#{type => object};
|
||||||
typename_to_spec("#{" ++ _, Mod) ->
|
typename_to_spec("port_number()", _Mod) ->
|
||||||
typename_to_spec("map()", Mod);
|
#{type => integer};
|
||||||
typename_to_spec(Name, Mod) ->
|
typename_to_spec(Name, Mod) ->
|
||||||
Spec = range(Name),
|
Spec = range(Name),
|
||||||
Spec1 = remote_module_type(Spec, Name, Mod),
|
Spec1 = remote_module_type(Spec, Name, Mod),
|
||||||
Spec2 = typerefl_array(Spec1, Name, Mod),
|
Spec2 = typerefl_array(Spec1, Name, Mod),
|
||||||
Spec3 = integer(Spec2, Name),
|
Spec3 = integer(Spec2, Name),
|
||||||
default_type(Spec3).
|
default_type(Mod, Name, Spec3).
|
||||||
|
|
||||||
default_type(nomatch) -> #{type => string};
|
default_type(Mod, Name, nomatch) ->
|
||||||
default_type(Type) -> Type.
|
error({unknown_type, Mod, Name});
|
||||||
|
default_type(_Mod, _Name, Type) ->
|
||||||
|
Type.
|
||||||
|
|
||||||
range(Name) ->
|
range(Name) ->
|
||||||
case string:split(Name, "..") of
|
case string:split(Name, "..") of
|
||||||
|
|
|
@ -845,20 +845,10 @@ typename_to_spec("timeout_duration_ms()", _Mod) ->
|
||||||
#{type => string, example => <<"32s">>};
|
#{type => string, example => <<"32s">>};
|
||||||
typename_to_spec("percent()", _Mod) ->
|
typename_to_spec("percent()", _Mod) ->
|
||||||
#{type => number, example => <<"12%">>};
|
#{type => number, example => <<"12%">>};
|
||||||
typename_to_spec("file()", _Mod) ->
|
|
||||||
#{type => string, example => <<"/path/to/file">>};
|
|
||||||
typename_to_spec("ip_port()", _Mod) ->
|
typename_to_spec("ip_port()", _Mod) ->
|
||||||
#{type => string, example => <<"127.0.0.1:80">>};
|
#{type => string, example => <<"127.0.0.1:80">>};
|
||||||
typename_to_spec("url()", _Mod) ->
|
typename_to_spec("url()", _Mod) ->
|
||||||
#{type => string, example => <<"http://127.0.0.1">>};
|
#{type => string, example => <<"http://127.0.0.1">>};
|
||||||
typename_to_spec("timeout()", _Mod) ->
|
|
||||||
#{
|
|
||||||
<<"oneOf">> => [
|
|
||||||
#{type => string, example => infinity},
|
|
||||||
#{type => integer}
|
|
||||||
],
|
|
||||||
example => infinity
|
|
||||||
};
|
|
||||||
typename_to_spec("bytesize()", _Mod) ->
|
typename_to_spec("bytesize()", _Mod) ->
|
||||||
#{type => string, example => <<"32MB">>};
|
#{type => string, example => <<"32MB">>};
|
||||||
typename_to_spec("wordsize()", _Mod) ->
|
typename_to_spec("wordsize()", _Mod) ->
|
||||||
|
@ -866,16 +856,8 @@ typename_to_spec("wordsize()", _Mod) ->
|
||||||
typename_to_spec("map(" ++ Map, _Mod) ->
|
typename_to_spec("map(" ++ Map, _Mod) ->
|
||||||
[$) | _MapArgs] = lists:reverse(Map),
|
[$) | _MapArgs] = lists:reverse(Map),
|
||||||
#{type => object, example => #{}};
|
#{type => object, example => #{}};
|
||||||
typename_to_spec("service_account_json()", _Mod) ->
|
|
||||||
#{type => object, example => #{}};
|
|
||||||
typename_to_spec("#{" ++ _, Mod) ->
|
|
||||||
typename_to_spec("map()", Mod);
|
|
||||||
typename_to_spec("qos()", _Mod) ->
|
typename_to_spec("qos()", _Mod) ->
|
||||||
#{type => integer, minimum => 0, maximum => 2, example => 0};
|
#{type => integer, minimum => 0, maximum => 2, example => 0};
|
||||||
typename_to_spec("{binary(), binary()}", _Mod) ->
|
|
||||||
#{type => object, example => #{}};
|
|
||||||
typename_to_spec("{string(), string()}", _Mod) ->
|
|
||||||
#{type => object, example => #{}};
|
|
||||||
typename_to_spec("comma_separated_list()", _Mod) ->
|
typename_to_spec("comma_separated_list()", _Mod) ->
|
||||||
#{type => string, example => <<"item1,item2">>};
|
#{type => string, example => <<"item1,item2">>};
|
||||||
typename_to_spec("comma_separated_binary()", _Mod) ->
|
typename_to_spec("comma_separated_binary()", _Mod) ->
|
||||||
|
|
Loading…
Reference in New Issue