From f8573ae8d7dade0592328fa17ffac27e92153ef4 Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Sun, 19 Mar 2023 12:34:06 +0800 Subject: [PATCH] fix: swagger doc 500 crash --- apps/emqx_conf/src/emqx_conf.erl | 2 +- apps/emqx_dashboard/src/emqx_dashboard.erl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/emqx_conf/src/emqx_conf.erl b/apps/emqx_conf/src/emqx_conf.erl index c64062861..33214946d 100644 --- a/apps/emqx_conf/src/emqx_conf.erl +++ b/apps/emqx_conf/src/emqx_conf.erl @@ -162,7 +162,7 @@ gen_schema_json(Dir, I18nFile, SchemaModule, Lang) -> ok = file:write_file(SchemaJsonFile, IoData). gen_api_schema_json(Dir, I18nFile, Lang) -> - emqx_dashboard:init_i18n(I18nFile, Lang), + emqx_dashboard:init_i18n(I18nFile, list_to_binary(Lang)), gen_api_schema_json_hotconf(Dir, Lang), gen_api_schema_json_bridge(Dir, Lang), emqx_dashboard:clear_i18n(). diff --git a/apps/emqx_dashboard/src/emqx_dashboard.erl b/apps/emqx_dashboard/src/emqx_dashboard.erl index 060045603..f0344dd5a 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard.erl @@ -133,8 +133,8 @@ get_i18n() -> application:get_env(emqx_dashboard, i18n). init_i18n(File, Lang) when is_atom(Lang) -> - init_i18n(File, atom_to_list(Lang)); -init_i18n(File, Lang) when is_list(Lang) -> + init_i18n(File, atom_to_binary(Lang)); +init_i18n(File, Lang) when is_binary(Lang) -> Cache = hocon_schema:new_desc_cache(File), application:set_env(emqx_dashboard, i18n, #{lang => Lang, cache => Cache}).