fix: generate connector & exhook & retainer api response code

This commit is contained in:
DDDHuang 2022-03-17 14:09:50 +08:00
parent 60f107f91f
commit 4d4348759d
4 changed files with 16 additions and 20 deletions

View File

@ -117,7 +117,7 @@ param_path_id() ->
[{id, mk(binary(),
#{ in => path
, example => <<"mqtt:my_mqtt_connector">>
, desc => <<"The connector Id. Must be of format {type}:{name}">>
, description => <<"The connector Id. Must be of format {type}:{name}">>
})}].
schema("/connectors_test") ->

View File

@ -92,12 +92,11 @@ stop_listeners() ->
%% internal
apps() ->
[emqx_management].
% [App || {App, _, _} <- application:loaded_applications(),
% case re:run(atom_to_list(App), "^emqx") of
% {match,[{0,4}]} -> true;
% _ -> false
% end].
[App || {App, _, _} <- application:loaded_applications(),
case re:run(atom_to_list(App), "^emqx") of
{match,[{0,4}]} -> true;
_ -> false
end].
listeners() ->
[begin

View File

@ -120,7 +120,7 @@ schema("/exhooks/:name/move") ->
}.
fields(move_req) ->
[{position, mk(string(), #{ desc => <<"The target position to be moved.">>
[{position, mk(string(), #{ description => <<"The target position to be moved.">>
, example => <<"front">>})}];
fields(detail_server_info) ->
@ -131,9 +131,9 @@ fields(detail_server_info) ->
] ++ emqx_exhook_schema:server_config();
fields(list_hook_info) ->
[ {name, mk(binary(), #{desc => <<"The hook's name">>})}
[ {name, mk(binary(), #{description => <<"The hook's name">>})}
, {params, mk(map(name, binary()),
#{desc => <<"The parameters used when the hook is registered">>})}
#{description => <<"The parameters used when the hook is registered">>})}
, {metrics, mk(ref(metrics), #{})}
, {node_metrics, mk(array(ref(node_metrics)), #{})}
];
@ -149,9 +149,9 @@ fields(node_status) ->
];
fields(hook_info) ->
[ {name, mk(binary(), #{desc => <<"The hook's name">>})}
[ {name, mk(binary(), #{description => <<"The hook's name">>})}
, {params, mk(map(name, binary()),
#{desc => <<"The parameters used when the hook is registered">>})}
#{description => <<"The parameters used when the hook is registered">>})}
];
fields(metrics) ->

View File

@ -55,7 +55,7 @@ schema(?PREFIX) ->
description => <<"Update retainer config">>,
'requestBody' => mk(conf_schema(), #{desc => "The config content"}),
responses => #{200 => mk(conf_schema(), #{desc => "Update configs successfully"}),
404 => error_codes(['UPDATE_FAILED'], <<"Update config failed">>)
400 => error_codes(['UPDATE_FAILED'], <<"Update config failed">>)
}
}
};
@ -66,7 +66,7 @@ schema(?PREFIX ++ "/messages") ->
description => <<"List retained messages">>,
parameters => page_params(),
responses => #{200 => mk(array(ref(message_summary)), #{desc => "The result list"}),
405 => error_codes(['ACTION_NOT_ALLOWED'], <<"Unsupported backend">>)
400 => error_codes(['BAD_REQUEST'], <<"Unsupported backend">>)
}
}
};
@ -78,14 +78,14 @@ schema(?PREFIX ++ "/message/:topic") ->
parameters => parameters(),
responses => #{200 => mk(ref(message), #{desc => "Details of the message"}),
404 => error_codes(['NOT_FOUND'], <<"Viewed message doesn't exist">>),
405 => error_codes(['ACTION_NOT_ALLOWED'], <<"Unsupported backend">>)
400 => error_codes(['BAD_REQUEST'], <<"Unsupported backend">>)
}
},
delete => #{tags => ?TAGS,
description => <<"Delete matching messages">>,
parameters => parameters(),
responses => #{204 => <<>>,
405 => error_codes(['ACTION_NOT_ALLOWED'],
400 => error_codes(['BAD_REQUEST'],
<<"Unsupported backend">>)
}
}
@ -191,8 +191,5 @@ check_backend(Type, Params, Cont) ->
built_in_database ->
Cont(Type, Params);
_ ->
{405,
#{code => <<"ACTION_NOT_ALLOWED">>,
message => <<"This API only for built in database">>}
}
{400, 'BAD_REQUEST', <<"This API only support built in database">>}
end.