From 8e2b1aed322404461b420d64993b1b85cc67bc42 Mon Sep 17 00:00:00 2001 From: DDDHuang <904897578@qq.com> Date: Mon, 2 Aug 2021 17:20:15 +0800 Subject: [PATCH] fix: publish api params --- .../src/emqx_mgmt_api_publish.erl | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_api_publish.erl b/apps/emqx_management/src/emqx_mgmt_api_publish.erl index 29e162b11..1e4555160 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_publish.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_publish.erl @@ -26,36 +26,32 @@ api_spec() -> { - [publish_api(), publish_batch_api()], + [publish_api(), publish_bulk_api()], [message_schema()] }. publish_api() -> + Schema = #{ + type => object, + properties => maps:without([id], message_properties()) + }, MeteData = #{ post => #{ description => <<"Publish">>, - 'requestBody' => #{ - content => #{ - 'application/json' => #{ - schema => #{ - type => object, - properties => maps:with([id], message_properties())}}}}, + 'requestBody' => emqx_mgmt_util:request_body_schema(Schema), responses => #{ <<"200">> => emqx_mgmt_util:response_schema(<<"publish ok">>, message)}}}, {"/publish", MeteData, publish}. -publish_batch_api() -> +publish_bulk_api() -> + Schema = #{ + type => object, + properties => maps:without([id], message_properties()) + }, MeteData = #{ post => #{ description => <<"publish">>, - 'requestBody' => #{ - content => #{ - 'application/json' => #{ - schema => #{ - type => array, - items => #{ - type => object, - properties => maps:with([id], message_properties())}}}}}, + 'requestBody' => emqx_mgmt_util:request_body_array_schema(Schema), responses => #{ <<"200">> => emqx_mgmt_util:response_array_schema(<<"publish ok">>, message)}}}, {"/publish/bulk", MeteData, publish_batch}.