fix(schema): add namespaces

This commit is contained in:
Zaiming (Stone) Shi 2023-11-28 12:07:42 +01:00
parent 1b1cea24f3
commit 6c85e62d26
6 changed files with 21 additions and 5 deletions

View File

@ -24,7 +24,7 @@
%%====================================================================================== %%======================================================================================
%% Hocon Schema Definitions %% Hocon Schema Definitions
namespace() -> "bridge_webhook". namespace() -> "bridge_http".
roots() -> []. roots() -> [].

View File

@ -12,7 +12,7 @@
-include_lib("snabbkaffe/include/snabbkaffe.hrl"). -include_lib("snabbkaffe/include/snabbkaffe.hrl").
-include_lib("hocon/include/hoconsc.hrl"). -include_lib("hocon/include/hoconsc.hrl").
-export([roots/0, fields/1, desc/1, connector_examples/1]). -export([namespace/0, roots/0, fields/1, desc/1, connector_examples/1]).
%% `emqx_resource' API %% `emqx_resource' API
-export([ -export([
@ -44,6 +44,8 @@
%% ------------------------------------------------------------------------------------------------- %% -------------------------------------------------------------------------------------------------
%% api %% api
namespace() -> "syskeeper_forwarder".
connector_examples(Method) -> connector_examples(Method) ->
[ [
#{ #{

View File

@ -306,7 +306,7 @@ gen_flat_doc(RootNames, #{full_name := FullName, fields := Fields} = S) ->
ShortName = short_name(FullName), ShortName = short_name(FullName),
case is_missing_namespace(ShortName, to_bin(FullName), RootNames) of case is_missing_namespace(ShortName, to_bin(FullName), RootNames) of
true -> true ->
io:format(standard_error, "WARN: no_namespace_for: ~s~n", [FullName]); error({no_namespace, FullName, S});
false -> false ->
ok ok
end, end,

View File

@ -4,12 +4,18 @@
-module(emqx_gbt32960_schema). -module(emqx_gbt32960_schema).
-behaviour(hocon_schema).
-include("emqx_gbt32960.hrl"). -include("emqx_gbt32960.hrl").
-include_lib("hocon/include/hoconsc.hrl"). -include_lib("hocon/include/hoconsc.hrl").
-include_lib("typerefl/include/types.hrl"). -include_lib("typerefl/include/types.hrl").
%% config schema provides %% config schema provides
-export([fields/1, desc/1]). -export([namespace/0, roots/0, fields/1, desc/1]).
namespace() -> "gateway_gbt32960".
roots() -> [].
fields(gbt32960) -> fields(gbt32960) ->
[ [

View File

@ -10,7 +10,11 @@
-define(DEFAULT_MOUNTPOINT, <<"ocpp/">>). -define(DEFAULT_MOUNTPOINT, <<"ocpp/">>).
%% config schema provides %% config schema provides
-export([fields/1, desc/1]). -export([namespace/0, roots/0, fields/1, desc/1]).
namespace() -> "gateway_ocpp".
roots() -> [].
fields(ocpp) -> fields(ocpp) ->
[ [

View File

@ -24,6 +24,7 @@
}). }).
-export([ -export([
namespace/0,
roots/0, roots/0,
fields/1, fields/1,
desc/1 desc/1
@ -37,6 +38,9 @@
-define(CONNECTOR_TYPE, pgsql). -define(CONNECTOR_TYPE, pgsql).
namespace() ->
"connector_postgres".
roots() -> roots() ->
[]. [].