fix(mongodb): add `type` and `name` fields to the `get`/`post` API docs

https://emqx.atlassian.net/browse/EMQX-8643

Adds thoses fields to MongoDB API docs so the frontend may use them to
render properly.
This commit is contained in:
Thales Macedo Garitezi 2023-01-03 11:46:58 -03:00
parent c9bd600fef
commit 4feaf5916f
2 changed files with 40 additions and 6 deletions

View File

@ -64,4 +64,26 @@ emqx_ee_bridge_mongodb {
zh: "MongoDB独立配置"
}
}
desc_type {
desc {
en: """The Bridge Type."""
zh: """桥接类型。"""
}
label {
en: "Bridge Type"
zh: "桥接类型"
}
}
desc_name {
desc {
en: """Bridge name."""
zh: """桥接名称。"""
}
label {
en: "Bridge Name"
zh: "桥接名称"
}
}
}

View File

@ -46,11 +46,11 @@ fields(mongodb_sharded) ->
fields(mongodb_single) ->
emqx_connector_mongo:fields(single) ++ fields("config");
fields("post_rs") ->
fields(mongodb_rs);
fields(mongodb_rs) ++ type_and_name_fields(mongodb_rs);
fields("post_sharded") ->
fields(mongodb_sharded);
fields(mongodb_sharded) ++ type_and_name_fields(mongodb_sharded);
fields("post_single") ->
fields(mongodb_single);
fields(mongodb_single) ++ type_and_name_fields(mongodb_single);
fields("put_rs") ->
fields(mongodb_rs);
fields("put_sharded") ->
@ -58,11 +58,17 @@ fields("put_sharded") ->
fields("put_single") ->
fields(mongodb_single);
fields("get_rs") ->
emqx_bridge_schema:metrics_status_fields() ++ fields(mongodb_rs);
emqx_bridge_schema:metrics_status_fields() ++
fields(mongodb_rs) ++
type_and_name_fields(mongodb_rs);
fields("get_sharded") ->
emqx_bridge_schema:metrics_status_fields() ++ fields(mongodb_sharded);
emqx_bridge_schema:metrics_status_fields() ++
fields(mongodb_sharded) ++
type_and_name_fields(mongodb_sharded);
fields("get_single") ->
emqx_bridge_schema:metrics_status_fields() ++ fields(mongodb_single).
emqx_bridge_schema:metrics_status_fields() ++
fields(mongodb_single) ++
type_and_name_fields(mongodb_single).
conn_bridge_examples(Method) ->
[
@ -103,6 +109,12 @@ desc(_) ->
%% Internal fns
%%=================================================================================================
type_and_name_fields(MongoType) ->
[
{type, mk(MongoType, #{required => true, desc => ?DESC("desc_type")})},
{name, mk(binary(), #{required => true, desc => ?DESC("desc_name")})}
].
values(mongodb_rs = MongoType, Method) ->
TypeOpts = #{
servers => <<"localhost:27017, localhost:27018">>,