From 36411edb42ea39efd411924bdfe3b29563a53a23 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Wed, 25 Oct 2023 17:19:51 +0200 Subject: [PATCH] feat: Add API endpoint /api/v5/schemas/bridges_v2 --- .../src/emqx_dashboard_schema_api.erl | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/emqx_dashboard/src/emqx_dashboard_schema_api.erl b/apps/emqx_dashboard/src/emqx_dashboard_schema_api.erl index e4f2f0c1a..321622b5c 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_schema_api.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_schema_api.erl @@ -14,7 +14,11 @@ %% limitations under the License. %%-------------------------------------------------------------------- -%% This module is for dashboard to retrieve the schema hot config and bridges. +%% This module is for dashboard to retrieve the schema of +%% 1. hot-config +%% 2. bridge +%% 3. bridge_v2 +%% 4. connector -module(emqx_dashboard_schema_api). -behaviour(minirest_api). @@ -45,7 +49,7 @@ schema("/schemas/:name") -> 'operationId' => get_schema, get => #{ parameters => [ - {name, hoconsc:mk(hoconsc:enum([hotconf, bridges]), #{in => path})} + {name, hoconsc:mk(hoconsc:enum([hotconf, bridges, bridges_v2]), #{in => path})} ], desc => << "Get the schema JSON of the specified name. " @@ -73,4 +77,17 @@ get_schema(get, _) -> gen_schema(hotconf) -> emqx_conf:hotconf_schema_json(); gen_schema(bridges) -> - emqx_conf:bridge_schema_json(). + emqx_conf:bridge_schema_json(); +gen_schema(bridges_v2) -> + bridge_v2_schema_json(). + +bridge_v2_schema_json() -> + SchemaInfo = #{title => <<"EMQX Data Bridge V2 API Schema">>, version => <<"0.1.0">>}, + gen_api_schema_json_iodata(emqx_bridge_v2_api, SchemaInfo). + +gen_api_schema_json_iodata(SchemaMod, SchemaInfo) -> + emqx_dashboard_swagger:gen_api_schema_json_iodata( + SchemaMod, + SchemaInfo, + fun emqx_conf:hocon_schema_to_spec/2 + ).