Merge pull request #11210 from sstrigler/EMQX-9569-provide-the-ce-ee-version-info-and-the-current-version-number-in-the-info-field

feat(emqx_dashboard): include edition and version in swagger.json info
This commit is contained in:
Stefan Strigler 2023-07-07 11:55:44 +02:00 committed by GitHub
commit 055a1e8d75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -49,7 +49,7 @@ start_listeners(Listeners) ->
Authorization = {?MODULE, authorize},
GlobalSpec = #{
openapi => "3.0.0",
info => #{title => "EMQX API", version => ?EMQX_API_VERSION},
info => #{title => emqx_api_name(), version => emqx_release_version()},
servers => [#{url => emqx_dashboard_swagger:base_path()}],
components => #{
schemas => #{},
@ -271,3 +271,9 @@ dynamic_dispatch() ->
{emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []},
{'_', emqx_dashboard_not_found, []}
].
emqx_api_name() ->
emqx_release:description() ++ " API".
emqx_release_version() ->
emqx_release:version().

View File

@ -149,6 +149,15 @@ t_swagger_json(_Config) ->
{ok, {{"HTTP/1.1", 200, "OK"}, _Headers, Body2}} =
httpc:request(get, {Url, []}, [], [{body_format, binary}]),
?assertEqual(Body1, Body2),
?assertMatch(
#{
<<"info">> := #{
<<"title">> := _,
<<"version">> := _
}
},
emqx_utils_json:decode(Body1)
),
ok.
t_cli(_Config) ->