From 09e5f35f5cc3c0b7225605c7bfb8adf174f28485 Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Thu, 12 May 2022 16:15:04 +0800 Subject: [PATCH 1/2] fix: include ref's desc --- apps/emqx_conf/i18n/emqx_conf_schema.conf | 8 ++++---- .../src/emqx_dashboard_swagger.erl | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/apps/emqx_conf/i18n/emqx_conf_schema.conf b/apps/emqx_conf/i18n/emqx_conf_schema.conf index df7d24cc2..88b155e50 100644 --- a/apps/emqx_conf/i18n/emqx_conf_schema.conf +++ b/apps/emqx_conf/i18n/emqx_conf_schema.conf @@ -944,8 +944,8 @@ until the RPC connection is considered lost.""" zh: """需要持久化到文件的日志处理进程列表。默认只有 default 一个处理进程。""" } label { - en: "File Handlers" - zh: "File Handlers" + en: "File Handler" + zh: "File Handler" } } @@ -1389,8 +1389,8 @@ Each sink is represented by a _log handler_, which can be configured independent zh: """日志处理进程将日志事件打印到 EMQX 控制台。""" } label { - en: "Console Log Handler" - zh: "控制台日志处理进程" + en: "Console Handler" + zh: "Console Handler" } } diff --git a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl index 4e4ebed57..7000fd5f3 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl @@ -429,8 +429,23 @@ trans_label(Spec, Hocon, Default) -> desc_struct(Hocon) -> case hocon_schema:field_schema(Hocon, desc) of - undefined -> hocon_schema:field_schema(Hocon, description); - Struct -> Struct + undefined -> + case hocon_schema:field_schema(Hocon, description) of + undefined -> + case Hocon of + ?R_REF(Mod, Name) -> + case erlang:function_exported(Mod, desc, 1) of + true -> Mod:desc(Name); + false -> undefined + end; + _ -> + undefined + end; + Struct1 -> + Struct1 + end; + Struct -> + Struct end. request_body(#{content := _} = Content, _Module, _Options) -> From af8cad3856e025b9603f034fb6403a3903a8768a Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Thu, 12 May 2022 16:16:46 +0800 Subject: [PATCH 2/2] chore: bump minirest to 1.3.3(force generate dispatch rule) --- .../src/emqx_dashboard_swagger.erl | 22 +++++++++---------- mix.exs | 2 +- rebar.config | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl index 7000fd5f3..976fa97cd 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl @@ -431,23 +431,21 @@ desc_struct(Hocon) -> case hocon_schema:field_schema(Hocon, desc) of undefined -> case hocon_schema:field_schema(Hocon, description) of - undefined -> - case Hocon of - ?R_REF(Mod, Name) -> - case erlang:function_exported(Mod, desc, 1) of - true -> Mod:desc(Name); - false -> undefined - end; - _ -> - undefined - end; - Struct1 -> - Struct1 + undefined -> get_ref_desc(Hocon); + Struct1 -> Struct1 end; Struct -> Struct end. +get_ref_desc(?R_REF(Mod, Name)) -> + case erlang:function_exported(Mod, desc, 1) of + true -> Mod:desc(Name); + false -> undefined + end; +get_ref_desc(_) -> + undefined. + request_body(#{content := _} = Content, _Module, _Options) -> {Content, []}; request_body([], _Module, _Options) -> diff --git a/mix.exs b/mix.exs index 50e39cd9e..b1e306ed8 100644 --- a/mix.exs +++ b/mix.exs @@ -57,7 +57,7 @@ defmodule EMQXUmbrella.MixProject do {:mria, github: "emqx/mria", tag: "0.2.5", override: true}, {:ekka, github: "emqx/ekka", tag: "0.12.6", override: true}, {:gen_rpc, github: "emqx/gen_rpc", tag: "2.8.1", override: true}, - {:minirest, github: "emqx/minirest", tag: "1.3.2", override: true}, + {:minirest, github: "emqx/minirest", tag: "1.3.3", override: true}, {:ecpool, github: "emqx/ecpool", tag: "0.5.2"}, {:replayq, "0.3.4", override: true}, {:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true}, diff --git a/rebar.config b/rebar.config index 164532b41..692a5dfed 100644 --- a/rebar.config +++ b/rebar.config @@ -57,7 +57,7 @@ , {mria, {git, "https://github.com/emqx/mria", {tag, "0.2.5"}}} , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.12.6"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}} - , {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.3.2"}}} + , {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.3.3"}}} , {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}} , {replayq, "0.3.4"} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}