From 3ffbb7decf36c3f19318ab737d434282811c8d01 Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Tue, 22 Aug 2023 11:32:55 +0200 Subject: [PATCH 1/3] fix: HTTP API /api/v5/publish schema The schema for the /api/v5/publish HTTP API endpoint was incorrect. For 400 (Bad Request) error it cannot return a list but the incorrect schema declared that the response could include a list. Fixes: https://emqx.atlassian.net/browse/EMQX-10837 https://github.com/emqx/emqx/issues/11488 --- apps/emqx_management/src/emqx_mgmt_api_publish.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_api_publish.erl b/apps/emqx_management/src/emqx_mgmt_api_publish.erl index ba486ab89..f0834af96 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_publish.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_publish.erl @@ -57,7 +57,7 @@ schema("/publish") -> responses => #{ ?ALL_IS_WELL => hoconsc:mk(hoconsc:ref(?MODULE, publish_ok)), ?PARTIALLY_OK => hoconsc:mk(hoconsc:ref(?MODULE, publish_error)), - ?BAD_REQUEST => bad_request_schema(), + ?BAD_REQUEST => hoconsc:mk(hoconsc:ref(?MODULE, bad_request)), ?DISPATCH_ERROR => hoconsc:mk(hoconsc:ref(?MODULE, publish_error)) } } @@ -196,11 +196,13 @@ fields(bad_request) -> [ {code, hoconsc:mk(string(), #{ - desc => <<"BAD_REQUEST">> + desc => <<"BAD_REQUEST">>, + example => ?RC_TOPIC_NAME_INVALID })}, {message, hoconsc:mk(binary(), #{ - desc => ?DESC(error_message) + desc => ?DESC(error_message), + example => to_binary(emqx_reason_codes:name(?RC_TOPIC_NAME_INVALID)) })} ]. From 88f7c2b4d888de83c070d850fb76fc937f7d5aab Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Tue, 22 Aug 2023 15:48:27 +0200 Subject: [PATCH 2/3] docs: changelog entry for HTTP publish bad request schema --- changes/ce/fix-11493.en.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/ce/fix-11493.en.md diff --git a/changes/ce/fix-11493.en.md b/changes/ce/fix-11493.en.md new file mode 100644 index 000000000..b05a0d02f --- /dev/null +++ b/changes/ce/fix-11493.en.md @@ -0,0 +1 @@ +Example for and documentation for /api/v5/publish bad request response has been fixed. Previously the documentation example said that the bad request response could return a list in the body which was not actually the case. From 19acd82436c4b4bf5fa4441c44a1a0f4923dd109 Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Tue, 22 Aug 2023 16:41:11 +0200 Subject: [PATCH 3/3] docs: fix change log entry according to @thalesmg's suggestion Co-authored-by: Thales Macedo Garitezi --- changes/ce/fix-11493.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/ce/fix-11493.en.md b/changes/ce/fix-11493.en.md index b05a0d02f..93874933a 100644 --- a/changes/ce/fix-11493.en.md +++ b/changes/ce/fix-11493.en.md @@ -1 +1 @@ -Example for and documentation for /api/v5/publish bad request response has been fixed. Previously the documentation example said that the bad request response could return a list in the body which was not actually the case. +Examples and documentation for /api/v5/publish bad request response have been fixed. Previously the documentation example said that the bad request response could return a list in the body which was not actually the case.