feat(dashboard): expose the `swagger_support` option

This commit is contained in:
firest 2024-01-25 22:58:16 +08:00
parent 3b0736fc67
commit c37097a150
3 changed files with 13 additions and 1 deletions

View File

@ -76,7 +76,8 @@ start_listeners(Listeners) ->
security => [#{'basicAuth' => []}, #{'bearerAuth' => []}], security => [#{'basicAuth' => []}, #{'bearerAuth' => []}],
swagger_global_spec => GlobalSpec, swagger_global_spec => GlobalSpec,
dispatch => dispatch(), dispatch => dispatch(),
middlewares => [?EMQX_MIDDLE, cowboy_router, cowboy_handler] middlewares => [?EMQX_MIDDLE, cowboy_router, cowboy_handler],
swagger_support => emqx:get_config([dashboard, swagger_support], true)
}, },
{OkListeners, ErrListeners} = {OkListeners, ErrListeners} =
lists:foldl( lists:foldl(

View File

@ -56,6 +56,7 @@ fields("dashboard") ->
} }
)}, )},
{cors, fun cors/1}, {cors, fun cors/1},
{swagger_support, fun swagger_support/1},
{i18n_lang, fun i18n_lang/1}, {i18n_lang, fun i18n_lang/1},
{bootstrap_users_file, {bootstrap_users_file,
?HOCON( ?HOCON(
@ -272,6 +273,11 @@ cors(required) -> false;
cors(desc) -> ?DESC(cors); cors(desc) -> ?DESC(cors);
cors(_) -> undefined. cors(_) -> undefined.
swagger_support(type) -> boolean();
swagger_support(default) -> true;
swagger_support(desc) -> ?DESC(swagger_support);
swagger_support(_) -> undefined.
%% TODO: change it to string type %% TODO: change it to string type
%% It will be up to the dashboard package which languages to support %% It will be up to the dashboard package which languages to support
i18n_lang(type) -> ?ENUM([en, zh]); i18n_lang(type) -> ?ENUM([en, zh]);

View File

@ -143,4 +143,9 @@ ssl_options.desc:
ssl_options.label: ssl_options.label:
"""SSL options""" """SSL options"""
swagger_support.desc:
"""Enable or disable support for swagger API documentation."""
swagger_support.label:
"""Swagger Support"""
} }