fix(emqx_resource): fix schema schema definition

This commit is contained in:
Zaiming Shi 2021-06-14 20:34:51 +02:00
parent 49f844b1dd
commit 9a78f812e1
3 changed files with 7 additions and 18 deletions

View File

@ -1,6 +1,5 @@
-module(emqx_schema). -module(emqx_schema).
% tmp
-dialyzer(no_return). -dialyzer(no_return).
-dialyzer(no_match). -dialyzer(no_match).
-dialyzer(no_contracts). -dialyzer(no_contracts).

View File

@ -18,7 +18,8 @@
-include_lib("typerefl/include/types.hrl"). -include_lib("typerefl/include/types.hrl").
-include_lib("emqx_resource/include/emqx_resource_behaviour.hrl"). -include_lib("emqx_resource/include/emqx_resource_behaviour.hrl").
-export([ schema/0 -export([ structs/0
, fields/1
]). ]).
%% callbacks of behaviour emqx_resource %% callbacks of behaviour emqx_resource
@ -34,6 +35,10 @@
-export([do_health_check/1]). -export([do_health_check/1]).
%%===================================================================== %%=====================================================================
structs() -> ["config"].
fields("config") -> schema().
schema() -> schema() ->
emqx_connector_schema_lib:relational_db_fields() ++ emqx_connector_schema_lib:relational_db_fields() ++
emqx_connector_schema_lib:ssl_fields(). emqx_connector_schema_lib:ssl_fields().

View File

@ -18,21 +18,6 @@
-export([check/2]). -export([check/2]).
-export([structs/0, fields/1]).
-behaviour(hocon_schema).
check(SchemaMod, Conf) -> check(SchemaMod, Conf) ->
_ = erlang:erase(res_schema_mod), hocon_schema:check(SchemaMod, Conf, #{nullable => false}).
erlang:put(res_schema_mod, SchemaMod),
hocon_schema:check(?MODULE, Conf).
structs() -> ["config"].
fields("config") ->
[fun(type) -> "schema";
(_) -> undefined
end];
fields("schema") ->
SchemaMod = erlang:get(res_schema_mod),
SchemaMod:schema().