diff --git a/apps/emqx_authn/src/emqx_authn.app.src b/apps/emqx_authn/src/emqx_authn.app.src index a291f2f61..8a5b29642 100644 --- a/apps/emqx_authn/src/emqx_authn.app.src +++ b/apps/emqx_authn/src/emqx_authn.app.src @@ -1,7 +1,7 @@ %% -*- mode: erlang -*- {application, emqx_authn, [ {description, "EMQX Authentication"}, - {vsn, "0.1.20"}, + {vsn, "0.1.21"}, {modules, []}, {registered, [emqx_authn_sup, emqx_authn_registry]}, {applications, [kernel, stdlib, emqx_resource, emqx_connector, ehttpc, epgsql, mysql, jose]}, diff --git a/apps/emqx_authn/src/simple_authn/emqx_authn_jwt.erl b/apps/emqx_authn/src/simple_authn/emqx_authn_jwt.erl index 0df9014b8..5fef89078 100644 --- a/apps/emqx_authn/src/simple_authn/emqx_authn_jwt.erl +++ b/apps/emqx_authn/src/simple_authn/emqx_authn_jwt.erl @@ -158,12 +158,15 @@ verify_claims(type) -> verify_claims(desc) -> ?DESC(?FUNCTION_NAME); verify_claims(default) -> - #{}; + []; verify_claims(validator) -> [fun do_check_verify_claims/1]; verify_claims(converter) -> - fun(VerifyClaims) -> - [{to_binary(K), V} || {K, V} <- maps:to_list(VerifyClaims)] + fun + (VerifyClaims) when is_map(VerifyClaims) -> + [{to_binary(K), V} || {K, V} <- maps:to_list(VerifyClaims)]; + (VerifyClaims) -> + VerifyClaims end; verify_claims(required) -> false; diff --git a/apps/emqx_dashboard/src/emqx_dashboard.erl b/apps/emqx_dashboard/src/emqx_dashboard.erl index 53e8c1f76..ca995990d 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard.erl @@ -59,6 +59,11 @@ start_listeners(Listeners) -> scheme => basic, description => <<"Authorize with [API Keys](https://www.emqx.io/docs/en/v5.0/admin/api.html#api-keys)">> + }, + 'bearerAuth' => #{ + type => http, + scheme => bearer, + description => <<"Authorize with Bearer Token">> } } } diff --git a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl index 4dda377cf..6e354e1cf 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl @@ -536,6 +536,7 @@ init_prop(Keys, Init, Type) -> format_prop(deprecated, Value) when is_boolean(Value) -> Value; format_prop(deprecated, _) -> true; +format_prop(default, []) -> []; format_prop(_, Schema) -> to_bin(Schema). trans_required(Spec, true, _) -> Spec#{required => true}; @@ -567,18 +568,7 @@ trans_description(Spec, Hocon, Options) -> Spec; Desc -> Desc1 = binary:replace(Desc, [<<"\n">>], <<"
">>, [global]), - maybe_add_summary_from_label(Spec#{description => Desc1}, Hocon, Options) - end. - -maybe_add_summary_from_label(Spec, Hocon, Options) -> - Label = - case desc_struct(Hocon) of - ?DESC(_, _) = Struct -> get_i18n(<<"label">>, Struct, undefined, Options); - _ -> undefined - end, - case Label of - undefined -> Spec; - _ -> Spec#{summary => Label} + Spec#{description => Desc1} end. get_i18n(Tag, ?DESC(Namespace, Id), Default, Options) -> @@ -970,13 +960,13 @@ to_bin(List) when is_list(List) -> to_bin(Boolean) when is_boolean(Boolean) -> Boolean; to_bin(Atom) when is_atom(Atom) -> atom_to_binary(Atom, utf8); to_bin({Type, Args}) -> - unicode:characters_to_binary(io_lib:format("~ts(~p)", [Type, Args])); + unicode:characters_to_binary(io_lib:format("~ts-~p", [Type, Args])); to_bin(X) -> X. parse_object(PropList = [_ | _], Module, Options) when is_list(PropList) -> {Props, Required, Refs} = parse_object_loop(PropList, Module, Options), - Object = #{<<"type">> => object, <<"properties">> => Props}, + Object = #{<<"type">> => object, <<"properties">> => fix_empty_props(Props)}, case Required of [] -> {Object, Refs}; _ -> {maps:put(required, Required, Object), Refs} @@ -1012,7 +1002,10 @@ parse_object_loop([{Name, Hocon} | Rest], Module, Options, Props, Required, Refs HoconType = hocon_schema:field_schema(Hocon, type), Init0 = init_prop([default | ?DEFAULT_FIELDS], #{}, Hocon), SchemaToSpec = schema_converter(Options), - Init = trans_desc(Init0, Hocon, SchemaToSpec, NameBin, Options), + Init = maps:remove( + summary, + trans_desc(Init0, Hocon, SchemaToSpec, NameBin, Options) + ), {Prop, Refs1} = SchemaToSpec(HoconType, Module), NewRequiredAcc = case is_required(Hocon) of @@ -1043,6 +1036,11 @@ is_hidden(Hocon) -> is_required(Hocon) -> hocon_schema:field_schema(Hocon, required) =:= true. +fix_empty_props([]) -> + #{}; +fix_empty_props(Props) -> + Props. + content(ApiSpec) -> content(ApiSpec, undefined). diff --git a/apps/emqx_management/src/emqx_mgmt_api_trace.erl b/apps/emqx_management/src/emqx_mgmt_api_trace.erl index 331c62681..579f977d8 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_trace.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_trace.erl @@ -344,9 +344,7 @@ fields(bytes) -> description => ?DESC(max_response_bytes), in => query, required => false, - default => 1000, - minimum => 0, - maximum => ?MAX_SINT32 + default => 1000 } )} ]; diff --git a/apps/emqx_prometheus/src/emqx_prometheus.app.src b/apps/emqx_prometheus/src/emqx_prometheus.app.src index a0d4dee04..147dcc28f 100644 --- a/apps/emqx_prometheus/src/emqx_prometheus.app.src +++ b/apps/emqx_prometheus/src/emqx_prometheus.app.src @@ -2,7 +2,7 @@ {application, emqx_prometheus, [ {description, "Prometheus for EMQX"}, % strict semver, bump manually! - {vsn, "5.0.11"}, + {vsn, "5.0.12"}, {modules, []}, {registered, [emqx_prometheus_sup]}, {applications, [kernel, stdlib, prometheus, emqx, emqx_management]}, diff --git a/apps/emqx_prometheus/src/emqx_prometheus_schema.erl b/apps/emqx_prometheus/src/emqx_prometheus_schema.erl index f8005f06b..370582304 100644 --- a/apps/emqx_prometheus/src/emqx_prometheus_schema.erl +++ b/apps/emqx_prometheus/src/emqx_prometheus_schema.erl @@ -59,7 +59,7 @@ fields("prometheus") -> ?HOCON( list({string(), string()}), #{ - default => #{}, + default => [], required => false, converter => fun ?MODULE:convert_headers/1, desc => ?DESC(headers) @@ -149,6 +149,8 @@ fields("prometheus") -> desc("prometheus") -> ?DESC(prometheus); desc(_) -> undefined. +convert_headers(<<>>) -> + []; convert_headers(Headers) when is_map(Headers) -> maps:fold( fun(K, V, Acc) ->