From bf827cffa871b2b14f29cd285e188cea0aefe503 Mon Sep 17 00:00:00 2001 From: DDDHuang <44492639+DDDHuang@users.noreply.github.com> Date: Wed, 13 Apr 2022 15:51:39 +0800 Subject: [PATCH] fix: authn bad examples --- apps/emqx_authn/src/emqx_authn_api.erl | 45 ++++++++++--------- .../src/emqx_dashboard_swagger.erl | 5 +-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/apps/emqx_authn/src/emqx_authn_api.erl b/apps/emqx_authn/src/emqx_authn_api.erl index 2d72f9245..d053b1c4b 100644 --- a/apps/emqx_authn/src/emqx_authn_api.erl +++ b/apps/emqx_authn/src/emqx_authn_api.erl @@ -1412,17 +1412,9 @@ authenticator_examples() -> status_metrics_example() -> #{ - metrics => #{ - matched => 0, - success => 0, - failed => 0, - rate => 0.0, - rate_last5m => 0.0, - rate_max => 0.0 - }, - node_metrics => [ - #{ - node => node(), + status_metrics => #{ + summary => <<"Authn status metrics">>, + value => #{ metrics => #{ matched => 0, success => 0, @@ -1430,16 +1422,29 @@ status_metrics_example() -> rate => 0.0, rate_last5m => 0.0, rate_max => 0.0 - } + }, + node_metrics => [ + #{ + node => node(), + metrics => #{ + matched => 0, + success => 0, + failed => 0, + rate => 0.0, + rate_last5m => 0.0, + rate_max => 0.0 + } + } + ], + status => connected, + node_status => [ + #{ + node => node(), + status => connected + } + ] } - ], - status => connected, - node_status => [ - #{ - node => node(), - status => connected - } - ] + } }. request_user_create_examples() -> diff --git a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl index f8fe6450c..a4bbe74fa 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl @@ -109,10 +109,7 @@ schema_with_example(Type, Example) -> -spec(schema_with_examples(hocon_schema:type(), map()) -> hocon_schema:field_schema_map()). schema_with_examples(Type, Examples) -> - %% Swagger can dynamically distinguish if there are multiple examples. - %% But explicitly declaring examples as plural - %% may cause some example structures to be incorrectly identified. - schema_with_example(Type, Examples). + hoconsc:mk(Type, #{examples => #{<<"examples">> => Examples}}). -spec(error_codes(list(atom())) -> hocon_schema:fields()). error_codes(Codes) ->