Merge pull request #10473 from zmstone/0421-refactor-delete-unused-schema-field
0421 refactor delete unused schema field
This commit is contained in:
commit
9b9731b943
|
@ -100,7 +100,6 @@ common_fields() ->
|
|||
maps:to_list(
|
||||
maps:without(
|
||||
[
|
||||
base_url,
|
||||
pool_type
|
||||
],
|
||||
maps:from_list(emqx_connector_http:fields(config))
|
||||
|
|
|
@ -114,7 +114,6 @@ authz_http_common_fields() ->
|
|||
maps:to_list(
|
||||
maps:without(
|
||||
[
|
||||
base_url,
|
||||
pool_type
|
||||
],
|
||||
maps:from_list(emqx_connector_http:fields(config))
|
||||
|
|
|
@ -230,7 +230,6 @@ http_common_fields() ->
|
|||
maps:to_list(
|
||||
maps:without(
|
||||
[
|
||||
base_url,
|
||||
pool_type
|
||||
],
|
||||
maps:from_list(connector_fields(http))
|
||||
|
|
|
@ -68,7 +68,7 @@ basic_config() ->
|
|||
)}
|
||||
] ++ webhook_creation_opts() ++
|
||||
proplists:delete(
|
||||
max_retries, proplists:delete(base_url, emqx_connector_http:fields(config))
|
||||
max_retries, emqx_connector_http:fields(config)
|
||||
).
|
||||
|
||||
request_config() ->
|
||||
|
|
|
@ -35,19 +35,14 @@
|
|||
reply_delegator/2
|
||||
]).
|
||||
|
||||
-type url() :: emqx_http_lib:uri_map().
|
||||
-reflect_type([url/0]).
|
||||
-typerefl_from_string({url/0, emqx_http_lib, uri_parse}).
|
||||
|
||||
-export([
|
||||
roots/0,
|
||||
fields/1,
|
||||
desc/1,
|
||||
validations/0,
|
||||
namespace/0
|
||||
]).
|
||||
|
||||
-export([check_ssl_opts/2, validate_method/1, join_paths/2]).
|
||||
-export([validate_method/1, join_paths/2]).
|
||||
|
||||
-type connect_timeout() :: emqx_schema:duration() | infinity.
|
||||
-type pool_type() :: random | hash.
|
||||
|
@ -69,20 +64,6 @@ roots() ->
|
|||
|
||||
fields(config) ->
|
||||
[
|
||||
{base_url,
|
||||
sc(
|
||||
url(),
|
||||
#{
|
||||
required => true,
|
||||
validator => fun
|
||||
(#{query := _Query}) ->
|
||||
{error, "There must be no query in the base_url"};
|
||||
(_) ->
|
||||
ok
|
||||
end,
|
||||
desc => ?DESC("base_url")
|
||||
}
|
||||
)},
|
||||
{connect_timeout,
|
||||
sc(
|
||||
emqx_schema:duration_ms(),
|
||||
|
@ -171,9 +152,6 @@ desc("request") ->
|
|||
desc(_) ->
|
||||
undefined.
|
||||
|
||||
validations() ->
|
||||
[{check_ssl_opts, fun check_ssl_opts/1}].
|
||||
|
||||
validate_method(M) when M =:= <<"post">>; M =:= <<"put">>; M =:= <<"get">>; M =:= <<"delete">> ->
|
||||
ok;
|
||||
validate_method(M) ->
|
||||
|
@ -578,18 +556,6 @@ make_method(M) when M == <<"PUT">>; M == <<"put">> -> put;
|
|||
make_method(M) when M == <<"GET">>; M == <<"get">> -> get;
|
||||
make_method(M) when M == <<"DELETE">>; M == <<"delete">> -> delete.
|
||||
|
||||
check_ssl_opts(Conf) ->
|
||||
check_ssl_opts("base_url", Conf).
|
||||
|
||||
check_ssl_opts(URLFrom, Conf) ->
|
||||
#{scheme := Scheme} = hocon_maps:get(URLFrom, Conf),
|
||||
SSL = hocon_maps:get("ssl", Conf),
|
||||
case {Scheme, maps:get(enable, SSL, false)} of
|
||||
{http, false} -> true;
|
||||
{https, true} -> true;
|
||||
{_, _} -> false
|
||||
end.
|
||||
|
||||
formalize_request(Method, BasePath, {Path, Headers, _Body}) when
|
||||
Method =:= get; Method =:= delete
|
||||
->
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
-compile(nowarn_export_all).
|
||||
-compile(export_all).
|
||||
|
||||
-type url() :: emqx_http_lib:uri_map().
|
||||
-reflect_type([url/0]).
|
||||
-typerefl_from_string({url/0, emqx_http_lib, uri_parse}).
|
||||
|
||||
all() -> emqx_common_test_helpers:all(?MODULE).
|
||||
|
||||
init_per_suite(Config) ->
|
||||
|
@ -314,7 +318,7 @@ t_sub_fields(_Config) ->
|
|||
ok.
|
||||
|
||||
t_complicated_type(_Config) ->
|
||||
Path = "/ref/complicated_type",
|
||||
Path = "/ref/complex_type",
|
||||
Object = #{
|
||||
<<"content">> => #{
|
||||
<<"application/json">> =>
|
||||
|
@ -633,14 +637,14 @@ schema("/error") ->
|
|||
}
|
||||
}
|
||||
};
|
||||
schema("/ref/complicated_type") ->
|
||||
schema("/ref/complex_type") ->
|
||||
#{
|
||||
operationId => test,
|
||||
post => #{
|
||||
responses => #{
|
||||
200 => [
|
||||
{no_neg_integer, hoconsc:mk(non_neg_integer(), #{})},
|
||||
{url, hoconsc:mk(emqx_connector_http:url(), #{})},
|
||||
{url, hoconsc:mk(url(), #{})},
|
||||
{server, hoconsc:mk(emqx_schema:ip_port(), #{})},
|
||||
{connect_timeout, hoconsc:mk(emqx_connector_http:connect_timeout(), #{})},
|
||||
{pool_type, hoconsc:mk(emqx_connector_http:pool_type(), #{})},
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
emqx_connector_http {
|
||||
|
||||
base_url.desc:
|
||||
"""The base URL is the URL includes only the scheme, host and port.<br/>
|
||||
When send an HTTP request, the real URL to be used is the concatenation of the base URL and the
|
||||
path parameter<br/>
|
||||
For example: `http://localhost:9901/`"""
|
||||
|
||||
base_url.label:
|
||||
"""Base Url"""
|
||||
|
||||
body.desc:
|
||||
"""HTTP request body."""
|
||||
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
emqx_connector_http {
|
||||
|
||||
base_url.desc:
|
||||
"""base URL 只包含host和port。<br/>
|
||||
发送HTTP请求时,真实的URL是由base URL 和 path parameter连接而成。<br/>
|
||||
示例:`http://localhost:9901/`"""
|
||||
|
||||
base_url.label:
|
||||
"""Base Url"""
|
||||
|
||||
body.desc:
|
||||
"""HTTP请求报文主体。"""
|
||||
|
||||
|
|
Loading…
Reference in New Issue