Merge pull request #10207 from sstrigler/EMQX-9286-use-label-from-i-18-n-files-as-summary-for-open-api-spec
feat(emqx_dashboard): use label as summary in OpenAPI spec
This commit is contained in:
commit
2803aff798
@ -457,7 +457,18 @@ trans_description(Spec, Hocon) ->
|
||||
Spec;
|
||||
Desc ->
|
||||
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.
|
||||
|
||||
get_i18n(Key, Struct, Default) ->
|
||||
|
||||
1
changes/ce/feat-10207.en.md
Normal file
1
changes/ce/feat-10207.en.md
Normal file
@ -0,0 +1 @@
|
||||
Use 'label' from i18n file as 'summary' in OpenAPI spec.
|
||||
Loading…
Reference in New Issue
Block a user