feat(emqx_dashboard): use label as summary in OpenAPI spec

This commit is contained in:
Stefan Strigler 2023-03-22 16:29:51 +01:00
parent 2ffe7e43b5
commit 2662f79ec0
1 changed files with 12 additions and 1 deletions

View File

@ -457,7 +457,18 @@ trans_description(Spec, Hocon) ->
Spec; Spec;
Desc -> Desc ->
Desc1 = binary:replace(Desc, [<<"\n">>], <<"<br/>">>, [global]), Desc1 = binary:replace(Desc, [<<"\n">>], <<"<br/>">>, [global]),
Spec#{description => Desc1} maybe_add_summary_from_label(Spec#{description => Desc1}, Hocon)
end.
maybe_add_summary_from_label(Spec, Hocon) ->
Label =
case desc_struct(Hocon) of
?DESC(_, _) = Struct -> get_i18n(<<"label">>, Struct, undefined);
_ -> undefined
end,
case Label of
undefined -> Spec;
_ -> Spec#{summary => Label}
end. end.
get_i18n(Key, Struct, Default) -> get_i18n(Key, Struct, Default) ->