Просмотр исходного кода

feat(http): add `is_template` as HTTP headers field property

is_template was designed to be type property.
however for HTTP headers, it's a map() type,
instead of creating a new type for it, it's easier to just
add it as a field property.
zmstone 1 год назад
Родитель
Сommit
5b38d592f0

+ 2 - 1
apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl

@@ -130,7 +130,8 @@ fields("request") ->
             })},
         {path, hoconsc:mk(emqx_schema:template(), #{required => false, desc => ?DESC("path")})},
         {body, hoconsc:mk(emqx_schema:template(), #{required => false, desc => ?DESC("body")})},
-        {headers, hoconsc:mk(map(), #{required => false, desc => ?DESC("headers")})},
+        {headers,
+            hoconsc:mk(map(), #{required => false, desc => ?DESC("headers"), is_template => true})},
         {max_retries,
             sc(
                 non_neg_integer(),

+ 2 - 1
apps/emqx_bridge_http/src/emqx_bridge_http_schema.erl

@@ -270,7 +270,8 @@ headers_field() ->
                     <<"content-type">> => <<"application/json">>,
                     <<"keep-alive">> => <<"timeout=5">>
                 },
-                desc => ?DESC("config_headers")
+                desc => ?DESC("config_headers"),
+                is_template => true
             }
         )}.
 

+ 5 - 1
apps/emqx_dashboard/src/emqx_dashboard_swagger.erl

@@ -57,7 +57,11 @@
     allowEmptyValue,
     deprecated,
     minimum,
-    maximum
+    maximum,
+    %% is_template is a type property,
+    %% but some exceptions are made for them to be field property
+    %% for example, HTTP headers (which is a map type)
+    is_template
 ]).
 
 -define(INIT_SCHEMA, #{