|
|
@@ -317,68 +317,72 @@ t_sub_fields(_Config) ->
|
|
|
validate(Path, Object, ExpectRefs),
|
|
|
ok.
|
|
|
|
|
|
-t_complicated_type(_Config) ->
|
|
|
+t_complex_type(_Config) ->
|
|
|
Path = "/ref/complex_type",
|
|
|
- Object = #{
|
|
|
- <<"content">> => #{
|
|
|
- <<"application/json">> =>
|
|
|
- #{
|
|
|
- <<"schema">> => #{
|
|
|
- <<"properties">> =>
|
|
|
- [
|
|
|
- {<<"no_neg_integer">>, #{minimum => 0, type => integer}},
|
|
|
- {<<"url">>, #{example => <<"http://127.0.0.1">>, type => string}},
|
|
|
- {<<"server">>, #{example => <<"127.0.0.1:80">>, type => string}},
|
|
|
- {<<"connect_timeout">>, #{
|
|
|
- example => infinity,
|
|
|
- <<"oneOf">> => [
|
|
|
- #{example => infinity, type => string},
|
|
|
- #{type => integer}
|
|
|
- ]
|
|
|
- }},
|
|
|
- {<<"pool_type">>, #{enum => [random, hash], type => string}},
|
|
|
- {<<"timeout">>, #{
|
|
|
- example => infinity,
|
|
|
- <<"oneOf">> => [
|
|
|
- #{example => infinity, type => string}, #{type => integer}
|
|
|
- ]
|
|
|
- }},
|
|
|
- {<<"bytesize">>, #{example => <<"32MB">>, type => string}},
|
|
|
- {<<"wordsize">>, #{example => <<"1024KB">>, type => string}},
|
|
|
- {<<"maps">>, #{example => #{}, type => object}},
|
|
|
- {<<"comma_separated_list">>, #{
|
|
|
- example => <<"item1,item2">>, type => string
|
|
|
- }},
|
|
|
- {<<"comma_separated_atoms">>, #{
|
|
|
- example => <<"item1,item2">>, type => string
|
|
|
- }},
|
|
|
- {<<"log_level">>, #{
|
|
|
- enum => [
|
|
|
- debug,
|
|
|
- info,
|
|
|
- notice,
|
|
|
- warning,
|
|
|
- error,
|
|
|
- critical,
|
|
|
- alert,
|
|
|
- emergency,
|
|
|
- all
|
|
|
- ],
|
|
|
- type => string
|
|
|
- }},
|
|
|
- {<<"fix_integer">>, #{
|
|
|
- default => 100, enum => [100], type => integer
|
|
|
- }}
|
|
|
- ],
|
|
|
- <<"type">> => object
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
{OperationId, Spec, Refs, #{}} = emqx_dashboard_swagger:parse_spec_ref(?MODULE, Path, #{}),
|
|
|
?assertEqual(test, OperationId),
|
|
|
Response = maps:get(responses, maps:get(post, Spec)),
|
|
|
- ?assertEqual(Object, maps:get(<<"200">>, Response)),
|
|
|
+ ResponseBody = maps:get(<<"200">>, Response),
|
|
|
+ Content = maps:get(<<"content">>, ResponseBody),
|
|
|
+ JsonContent = maps:get(<<"application/json">>, Content),
|
|
|
+ Schema = maps:get(<<"schema">>, JsonContent),
|
|
|
+ ?assertMatch(#{<<"type">> := object}, Schema),
|
|
|
+ Properties = maps:get(<<"properties">>, Schema),
|
|
|
+ ?assertMatch(
|
|
|
+ [
|
|
|
+ {<<"no_neg_integer">>, #{minimum := 0, type := integer}},
|
|
|
+ {<<"url">>, #{
|
|
|
+ example := <<"http://127.0.0.1">>, type := string
|
|
|
+ }},
|
|
|
+ {<<"server">>, #{
|
|
|
+ example := <<"127.0.0.1:80">>, type := string
|
|
|
+ }},
|
|
|
+ {<<"connect_timeout">>, #{
|
|
|
+ example := _, type := string
|
|
|
+ }},
|
|
|
+ {<<"pool_type">>, #{
|
|
|
+ enum := [random, hash], type := string
|
|
|
+ }},
|
|
|
+ {<<"timeout">>, #{
|
|
|
+ example := infinity,
|
|
|
+ <<"oneOf">> := [
|
|
|
+ #{example := infinity, type := string},
|
|
|
+ #{type := integer}
|
|
|
+ ]
|
|
|
+ }},
|
|
|
+ {<<"bytesize">>, #{
|
|
|
+ example := <<"32MB">>, type := string
|
|
|
+ }},
|
|
|
+ {<<"wordsize">>, #{
|
|
|
+ example := <<"1024KB">>, type := string
|
|
|
+ }},
|
|
|
+ {<<"maps">>, #{example := #{}, type := object}},
|
|
|
+ {<<"comma_separated_list">>, #{
|
|
|
+ example := <<"item1,item2">>, type := string
|
|
|
+ }},
|
|
|
+ {<<"comma_separated_atoms">>, #{
|
|
|
+ example := <<"item1,item2">>, type := string
|
|
|
+ }},
|
|
|
+ {<<"log_level">>, #{
|
|
|
+ enum := [
|
|
|
+ debug,
|
|
|
+ info,
|
|
|
+ notice,
|
|
|
+ warning,
|
|
|
+ error,
|
|
|
+ critical,
|
|
|
+ alert,
|
|
|
+ emergency,
|
|
|
+ all
|
|
|
+ ],
|
|
|
+ type := string
|
|
|
+ }},
|
|
|
+ {<<"fix_integer">>, #{
|
|
|
+ default := 100, enum := [100], type := integer
|
|
|
+ }}
|
|
|
+ ],
|
|
|
+ Properties
|
|
|
+ ),
|
|
|
?assertEqual([], Refs),
|
|
|
ok.
|
|
|
|
|
|
@@ -647,9 +651,8 @@ schema("/ref/complex_type") ->
|
|
|
{no_neg_integer, hoconsc:mk(non_neg_integer(), #{})},
|
|
|
{url, hoconsc:mk(url(), #{})},
|
|
|
{server, hoconsc:mk(emqx_schema:ip_port(), #{})},
|
|
|
- {connect_timeout,
|
|
|
- hoconsc:mk(emqx_bridge_http_connector:connect_timeout(), #{})},
|
|
|
- {pool_type, hoconsc:mk(emqx_bridge_http_connector:pool_type(), #{})},
|
|
|
+ {connect_timeout, hoconsc:mk(emqx_schema:timeout_duration(), #{})},
|
|
|
+ {pool_type, hoconsc:mk(hoconsc:enum([random, hash]), #{})},
|
|
|
{timeout, hoconsc:mk(timeout(), #{})},
|
|
|
{bytesize, hoconsc:mk(emqx_schema:bytesize(), #{})},
|
|
|
{wordsize, hoconsc:mk(emqx_schema:wordsize(), #{})},
|