refactor(api): mgmt_status (node running status) swagger spec
This commit is contained in:
parent
8eb7bf261c
commit
d3381710cd
|
@ -17,22 +17,40 @@
|
||||||
%% API
|
%% API
|
||||||
-behaviour(minirest_api).
|
-behaviour(minirest_api).
|
||||||
|
|
||||||
-export([api_spec/0]).
|
-export([ api_spec/0
|
||||||
|
, paths/0
|
||||||
|
, schema/1
|
||||||
|
]).
|
||||||
|
|
||||||
-export([running_status/2]).
|
-export([running_status/2]).
|
||||||
|
|
||||||
api_spec() ->
|
api_spec() ->
|
||||||
{[status_api()], []}.
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||||
|
|
||||||
status_api() ->
|
paths() ->
|
||||||
Path = "/status",
|
["/status"].
|
||||||
Metadata = #{
|
|
||||||
get => #{
|
schema("/status") ->
|
||||||
security => [],
|
#{ 'operationId' => running_status
|
||||||
responses => #{<<"200">> => #{description => <<"running">>}}
|
, get =>
|
||||||
}
|
#{ description => <<"Node running status">>
|
||||||
},
|
, security => []
|
||||||
{Path, Metadata, running_status}.
|
, responses =>
|
||||||
|
#{200 =>
|
||||||
|
#{ desc => <<"Node is running">>
|
||||||
|
, content =>
|
||||||
|
#{ 'text/plain' =>
|
||||||
|
#{ schema => #{type => string}
|
||||||
|
, example => <<"Node emqx@127.0.0.1 is started\nemqx is running">>}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% API Handler funcs
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
running_status(get, _Params) ->
|
running_status(get, _Params) ->
|
||||||
{InternalStatus, _ProvidedStatus} = init:get_status(),
|
{InternalStatus, _ProvidedStatus} = init:get_status(),
|
||||||
|
@ -44,5 +62,3 @@ running_status(get, _Params) ->
|
||||||
Status = io_lib:format("Node ~ts is ~ts~nemqx is ~ts", [node(), InternalStatus, AppStatus]),
|
Status = io_lib:format("Node ~ts is ~ts~nemqx is ~ts", [node(), InternalStatus, AppStatus]),
|
||||||
Body = list_to_binary(Status),
|
Body = list_to_binary(Status),
|
||||||
{200, #{<<"content-type">> => <<"text/plain">>}, Body}.
|
{200, #{<<"content-type">> => <<"text/plain">>}, Body}.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue