refactor(schema): ensure roots/0 and namespace/0 for all schema modules

This commit is contained in:
Zaiming (Stone) Shi 2024-02-15 22:57:34 +01:00
parent a389d78b42
commit f57f617ba3
44 changed files with 150 additions and 49 deletions

View File

@ -42,7 +42,8 @@
-export([ -export([
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1 schema/1,
namespace/0
]). ]).
-export([ -export([
@ -95,6 +96,8 @@
-elvis([{elvis_style, god_modules, disable}]). -elvis([{elvis_style, god_modules, disable}]).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -41,7 +41,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -56,6 +57,9 @@
-define(TAGS, [<<"Authorization">>]). -define(TAGS, [<<"Authorization">>]).
namespace() ->
undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -22,7 +22,8 @@
-export([ -export([
roots/0, roots/0,
fields/1, fields/1,
desc/1 desc/1,
namespace/0
]). ]).
-export([ -export([
@ -65,6 +66,8 @@
roots() -> []. roots() -> [].
namespace() -> undefined.
fields(?CONF_NS) -> fields(?CONF_NS) ->
emqx_schema:authz_fields() ++ authz_fields(); emqx_schema:authz_fields() ++ authz_fields();
fields("metrics_status_fields") -> fields("metrics_status_fields") ->

View File

@ -35,7 +35,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
%% operation funs %% operation funs
@ -69,6 +70,8 @@
-define(PUT_MAP_EXAMPLE, in_put_requestBody). -define(PUT_MAP_EXAMPLE, in_put_requestBody).
-define(POST_ARRAY_EXAMPLE, in_post_requestBody). -define(POST_ARRAY_EXAMPLE, in_post_requestBody).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -13,7 +13,8 @@
examples/1, examples/1,
resource_type/1, resource_type/1,
bridge_impl_module/1, bridge_impl_module/1,
fields/1 fields/1,
namespace/0
]). ]).
api_schemas(Method) -> api_schemas(Method) ->
@ -139,6 +140,8 @@ bridge_impl_module(azure_event_hub_producer) ->
bridge_impl_module(_BridgeType) -> bridge_impl_module(_BridgeType) ->
undefined. undefined.
namespace() -> undefined.
fields(bridges) -> fields(bridges) ->
[ [
{hstreamdb, {hstreamdb,

View File

@ -14,7 +14,7 @@
-include_lib("snabbkaffe/include/snabbkaffe.hrl"). -include_lib("snabbkaffe/include/snabbkaffe.hrl").
%% schema %% schema
-export([roots/0, fields/1, desc/1]). -export([roots/0, fields/1, desc/1, namespace/0]).
%% callbacks of behaviour emqx_resource %% callbacks of behaviour emqx_resource
-export([ -export([
@ -56,6 +56,8 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% schema %% schema
namespace() -> cassandra.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_clickhouse, [ {application, emqx_bridge_clickhouse, [
{description, "EMQX Enterprise ClickHouse Bridge"}, {description, "EMQX Enterprise ClickHouse Bridge"},
{vsn, "0.2.4"}, {vsn, "0.2.5"},
{registered, []}, {registered, []},
{applications, [ {applications, [
kernel, kernel,

View File

@ -23,7 +23,8 @@
-export([ -export([
roots/0, roots/0,
fields/1, fields/1,
values/1 values/1,
namespace/0
]). ]).
%% callbacks for behaviour emqx_resource %% callbacks for behaviour emqx_resource
@ -72,6 +73,8 @@
%% Configuration and default values %% Configuration and default values
%%===================================================================== %%=====================================================================
namespace() -> clickhouse.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_dynamo, [ {application, emqx_bridge_dynamo, [
{description, "EMQX Enterprise Dynamo Bridge"}, {description, "EMQX Enterprise Dynamo Bridge"},
{vsn, "0.1.4"}, {vsn, "0.1.5"},
{registered, []}, {registered, []},
{applications, [ {applications, [
kernel, kernel,

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]). -export([roots/0, fields/1, namespace/0]).
%% `emqx_resource' API %% `emqx_resource' API
-export([ -export([
@ -32,6 +32,9 @@
%%===================================================================== %%=====================================================================
%% Hocon schema %% Hocon schema
namespace() -> dynamodka.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -115,7 +115,8 @@ action_values() ->
%% ------------------------------------------------------------------------------------------------- %% -------------------------------------------------------------------------------------------------
%% Hocon Schema Definitions %% Hocon Schema Definitions
namespace() -> "bridge_rocketmq".
namespace() -> "rocketmq".
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]). -export([roots/0, fields/1, namespace/0]).
%% `emqx_resource' API %% `emqx_resource' API
-export([ -export([
@ -36,6 +36,9 @@
%%===================================================================== %%=====================================================================
%% Hocon schema %% Hocon schema
namespace() -> rocketmq.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_sqlserver, [ {application, emqx_bridge_sqlserver, [
{description, "EMQX Enterprise SQL Server Bridge"}, {description, "EMQX Enterprise SQL Server Bridge"},
{vsn, "0.1.5"}, {vsn, "0.1.6"},
{registered, []}, {registered, []},
{applications, [kernel, stdlib, emqx_resource, odbc]}, {applications, [kernel, stdlib, emqx_resource, odbc]},
{env, []}, {env, []},

View File

@ -24,7 +24,8 @@
%% Hocon config schema exports %% Hocon config schema exports
-export([ -export([
roots/0, roots/0,
fields/1 fields/1,
namespace/0
]). ]).
%% callbacks for behaviour emqx_resource %% callbacks for behaviour emqx_resource
@ -132,6 +133,8 @@
%% Configuration and default values %% Configuration and default values
%%==================================================================== %%====================================================================
namespace() -> sqlserver.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -44,12 +44,6 @@
password/0 password/0
]). ]).
-export([roots/0, fields/1]).
roots() -> [].
fields(_) -> [].
ssl_fields() -> ssl_fields() ->
[ [
{ssl, #{ {ssl, #{

View File

@ -15,8 +15,8 @@
-export([ -export([
api_schemas/1, api_schemas/1,
fields/1, fields/1,
%%examples/1 schema_modules/0,
schema_modules/0 namespace/0
]). ]).
resource_type(Type) when is_binary(Type) -> resource_type(Type) when is_binary(Type) ->
@ -93,6 +93,8 @@ connector_impl_module(rabbitmq) ->
connector_impl_module(_ConnectorType) -> connector_impl_module(_ConnectorType) ->
undefined. undefined.
namespace() -> undefined.
fields(connectors) -> fields(connectors) ->
connector_structs(). connector_structs().

View File

@ -27,7 +27,8 @@
-export([ -export([
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -35,6 +36,8 @@
monitor_current/2 monitor_current/2
]). ]).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).

View File

@ -19,7 +19,7 @@
-behaviour(hocon_schema). -behaviour(hocon_schema).
%% API %% API
-export([paths/0, api_spec/0, schema/1, namespace/0, fields/1]). -export([paths/0, api_spec/0, schema/1, roots/0, namespace/0, fields/1]).
-export([init_per_suite/1, end_per_suite/1]). -export([init_per_suite/1, end_per_suite/1]).
-export([t_in_path/1, t_in_query/1, t_in_mix/1, t_without_in/1, t_ref/1, t_public_ref/1]). -export([t_in_path/1, t_in_query/1, t_in_mix/1, t_without_in/1, t_ref/1, t_public_ref/1]).
-export([t_require/1, t_query_enum/1, t_nullable/1, t_method/1, t_api_spec/1]). -export([t_require/1, t_query_enum/1, t_nullable/1, t_method/1, t_api_spec/1]).
@ -563,6 +563,7 @@ schema("/method/error") ->
#{operationId => test, bar => #{200 => <<"ok">>}}. #{operationId => test, bar => #{200 => <<"ok">>}}.
namespace() -> undefined. namespace() -> undefined.
roots() -> [].
fields(page) -> fields(page) ->
[ [

View File

@ -17,9 +17,10 @@
-include_lib("typerefl/include/types.hrl"). -include_lib("typerefl/include/types.hrl").
-export([roots/0, fields/1]). -export([namespace/0, roots/0, fields/1]).
-import(hoconsc, [mk/2]). -import(hoconsc, [mk/2]).
roots() -> ["root"]. roots() -> ["root"].
namespace() -> undefined.
fields("root") -> fields("root") ->
[ [

View File

@ -813,7 +813,8 @@ to_schema(Body) ->
post => #{requestBody => Body, responses => #{200 => <<"ok">>}} post => #{requestBody => Body, responses => #{200 => <<"ok">>}}
}. }.
%% Don't warning hocon callback namespace/0 undef. roots() -> [].
namespace() -> atom_to_list(?MODULE). namespace() -> atom_to_list(?MODULE).
fields(good_ref) -> fields(good_ref) ->

View File

@ -680,6 +680,7 @@ to_schema(Object) ->
post => #{responses => #{200 => Object, 201 => Object}} post => #{responses => #{200 => Object, 201 => Object}}
}. }.
rotos() -> [].
namespace() -> undefined. namespace() -> undefined.
fields(good_ref) -> fields(good_ref) ->

View File

@ -36,7 +36,8 @@
-export([ -export([
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1 schema/1,
namespace/0
]). ]).
-export([ -export([
@ -59,6 +60,8 @@
%% minirest behaviour callbacks %% minirest behaviour callbacks
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -42,7 +42,8 @@
-export([ -export([
roots/0, roots/0,
fields/1 fields/1,
namespace/0
]). ]).
%% http handlers %% http handlers
@ -775,6 +776,8 @@ schema_client() ->
examples_client() examples_client()
). ).
namespace() -> undefined.
roots() -> roots() ->
[ [
stomp_client, stomp_client,

View File

@ -45,7 +45,8 @@
-export([ -export([
roots/0, roots/0,
fields/1 fields/1,
namespace/0
]). ]).
%% http handlers %% http handlers
@ -651,6 +652,9 @@ params_paging_in_qs() ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% schemas %% schemas
namespace() ->
undefined.
roots() -> roots() ->
[listener]. [listener].

View File

@ -9,10 +9,12 @@
-include_lib("typerefl/include/types.hrl"). -include_lib("typerefl/include/types.hrl").
-behaviour(hocon_schema). -behaviour(hocon_schema).
-export([namespace/0, fields/1, desc/1]). -export([roots/0, namespace/0, fields/1, desc/1]).
-define(NOT_EMPTY(MSG), emqx_resource_validator:not_empty(MSG)). -define(NOT_EMPTY(MSG), emqx_resource_validator:not_empty(MSG)).
roots() -> [].
namespace() -> gateway. namespace() -> gateway.
fields(jt808) -> fields(jt808) ->

View File

@ -1,6 +1,6 @@
{application, emqx_gcp_device, [ {application, emqx_gcp_device, [
{description, "Application simplifying migration from GCP IoT Core"}, {description, "Application simplifying migration from GCP IoT Core"},
{vsn, "0.1.3"}, {vsn, "0.1.4"},
{registered, []}, {registered, []},
{mod, {emqx_gcp_device_app, []}}, {mod, {emqx_gcp_device_app, []}},
{applications, [ {applications, [

View File

@ -22,7 +22,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -62,6 +63,9 @@
%% `minirest' and `minirest_trails' API %% `minirest' and `minirest_trails' API
%%------------------------------------------------------------------------------------------------- %%-------------------------------------------------------------------------------------------------
namespace() ->
undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -22,7 +22,7 @@
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").
-include_lib("typerefl/include/types.hrl"). -include_lib("typerefl/include/types.hrl").
-export([api_spec/0, paths/0, schema/1, fields/1]). -export([api_spec/0, paths/0, schema/1, fields/1, namespace/0]).
-export([alarms/2, format_alarm/2]). -export([alarms/2, format_alarm/2]).
@ -31,6 +31,9 @@
%% internal export (for query) %% internal export (for query)
-export([qs2ms/2]). -export([qs2ms/2]).
namespace() ->
undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -28,7 +28,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([format/1]). -export([format/1]).
@ -44,6 +45,9 @@
-define(FORMAT_FUN, {?MODULE, format}). -define(FORMAT_FUN, {?MODULE, format}).
namespace() ->
undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).

View File

@ -32,7 +32,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -83,6 +84,8 @@
message => <<"Client ID not found">> message => <<"Client ID not found">>
}). }).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).

View File

@ -21,7 +21,7 @@
-include_lib("emqx/include/logger.hrl"). -include_lib("emqx/include/logger.hrl").
-include_lib("hocon/include/hoconsc.hrl"). -include_lib("hocon/include/hoconsc.hrl").
-export([api_spec/0, paths/0, schema/1, fields/1]). -export([api_spec/0, paths/0, schema/1, fields/1, namespace/0]).
-export([ -export([
data_export/2, data_export/2,
@ -48,6 +48,8 @@
})} })}
). ).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -27,7 +27,8 @@
-export([ -export([
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1 schema/1,
namespace/0
]). ]).
-export([ -export([
@ -42,6 +43,8 @@
%% minirest behaviour callbacks %% minirest behaviour callbacks
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -30,7 +30,8 @@
api_spec/0, api_spec/0,
schema/1, schema/1,
paths/0, paths/0,
fields/1 fields/1,
namespace/0
]). ]).
%% API callbacks %% API callbacks
@ -45,6 +46,8 @@
%% API spec funcs %% API spec funcs
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -32,7 +32,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -40,6 +41,8 @@
publish_batch/2 publish_batch/2
]). ]).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).

View File

@ -34,11 +34,14 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([list/2]). -export([list/2]).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -28,7 +28,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([subscriptions/2]). -export([subscriptions/2]).
@ -48,6 +49,9 @@
{<<"match_topic">>, binary} {<<"match_topic">>, binary}
]). ]).
namespace() ->
undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -28,7 +28,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -41,6 +42,8 @@
-define(TOPICS_QUERY_SCHEMA, [{<<"topic">>, binary}, {<<"node">>, atom}]). -define(TOPICS_QUERY_SCHEMA, [{<<"topic">>, binary}, {<<"node">>, atom}]).
-define(TAGS, [<<"Topics">>]). -define(TAGS, [<<"Topics">>]).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).

View File

@ -34,7 +34,8 @@
-export([ -export([
paths/0, paths/0,
fields/1, fields/1,
schema/1 schema/1,
namespace/0
]). ]).
%% for rpc %% for rpc
@ -55,6 +56,8 @@
-define(INVALID_TOPIC, 'INVALID_TOPIC_NAME'). -define(INVALID_TOPIC, 'INVALID_TOPIC_NAME').
-define(MESSAGE_NOT_FOUND, 'MESSAGE_NOT_FOUND'). -define(MESSAGE_NOT_FOUND, 'MESSAGE_NOT_FOUND').
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -47,7 +47,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-define(EXCEED_LIMIT, 'EXCEED_LIMIT'). -define(EXCEED_LIMIT, 'EXCEED_LIMIT').
@ -55,6 +56,8 @@
-define(TOPIC_NOT_FOUND, 'TOPIC_NOT_FOUND'). -define(TOPIC_NOT_FOUND, 'TOPIC_NOT_FOUND').
-define(BAD_REQUEST, 'BAD_REQUEST'). -define(BAD_REQUEST, 'BAD_REQUEST').
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -44,7 +44,7 @@
unprepare_sql/1 unprepare_sql/1
]). ]).
-export([roots/0, fields/1]). -export([roots/0, fields/1, namespace/0]).
-export([do_get_status/1]). -export([do_get_status/1]).
@ -63,6 +63,9 @@
-export_type([state/0]). -export_type([state/0]).
%%===================================================================== %%=====================================================================
%% Hocon schema %% Hocon schema
namespace() -> mysql.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -12,9 +12,12 @@
%% Hocon config schema exports %% Hocon config schema exports
-export([ -export([
roots/0, roots/0,
fields/1 fields/1,
namespace/0
]). ]).
namespace() -> oracle.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?REF_MODULE, config)}}]. [{config, #{type => hoconsc:ref(?REF_MODULE, config)}}].

View File

@ -23,7 +23,7 @@
-include_lib("epgsql/include/epgsql.hrl"). -include_lib("epgsql/include/epgsql.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl"). -include_lib("snabbkaffe/include/snabbkaffe.hrl").
-export([roots/0, fields/1]). -export([roots/0, fields/1, namespace/0]).
-behaviour(emqx_resource). -behaviour(emqx_resource).
@ -71,6 +71,8 @@
%%===================================================================== %%=====================================================================
namespace() -> postgres.
roots() -> roots() ->
[{config, #{type => hoconsc:ref(?MODULE, config)}}]. [{config, #{type => hoconsc:ref(?MODULE, config)}}].

View File

@ -34,7 +34,8 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-export([ -export([
@ -50,6 +51,8 @@
-define(IS_TRUE(Val), ((Val =:= true) orelse (Val =:= <<"true">>))). -define(IS_TRUE(Val), ((Val =:= true) orelse (Val =:= <<"true">>))).
-define(IS_FALSE(Val), ((Val =:= false) orelse (Val =:= <<"false">>))). -define(IS_FALSE(Val), ((Val =:= false) orelse (Val =:= <<"false">>))).
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).

View File

@ -32,12 +32,15 @@
api_spec/0, api_spec/0,
paths/0, paths/0,
schema/1, schema/1,
fields/1 fields/1,
namespace/0
]). ]).
-define(BAD_REQUEST, 'BAD_REQUEST'). -define(BAD_REQUEST, 'BAD_REQUEST').
-define(NOT_FOUND, 'NOT_FOUND'). -define(NOT_FOUND, 'NOT_FOUND').
namespace() -> undefined.
api_spec() -> api_spec() ->
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}). emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).