|
@@ -297,6 +297,18 @@ trans_required(Spec, true, _) -> Spec#{required => true};
|
|
|
trans_required(Spec, _, path) -> Spec#{required => true};
|
|
trans_required(Spec, _, path) -> Spec#{required => true};
|
|
|
trans_required(Spec, _, _) -> Spec.
|
|
trans_required(Spec, _, _) -> Spec.
|
|
|
|
|
|
|
|
|
|
+trans_desc(Init, Hocon, Func, Name) ->
|
|
|
|
|
+ Spec0 = trans_desc(Init, Hocon),
|
|
|
|
|
+ case Func =:= fun hocon_schema_to_spec/2 of
|
|
|
|
|
+ true -> Spec0;
|
|
|
|
|
+ false ->
|
|
|
|
|
+ Spec1 = Spec0#{label => Name},
|
|
|
|
|
+ case Spec1 of
|
|
|
|
|
+ #{description := _} -> Spec1;
|
|
|
|
|
+ _ -> Spec1#{description => <<"TODO(Rquired description): ", Name/binary>>}
|
|
|
|
|
+ end
|
|
|
|
|
+ end.
|
|
|
|
|
+
|
|
|
trans_desc(Spec, Hocon) ->
|
|
trans_desc(Spec, Hocon) ->
|
|
|
case hocon_schema:field_schema(Hocon, desc) of
|
|
case hocon_schema:field_schema(Hocon, desc) of
|
|
|
undefined -> Spec;
|
|
undefined -> Spec;
|
|
@@ -333,7 +345,8 @@ response(Status, ?R_REF(_Mod, _Name) = RRef, {Acc, RefsAcc, Module, Options}) ->
|
|
|
SchemaToSpec = schema_converter(Options),
|
|
SchemaToSpec = schema_converter(Options),
|
|
|
{Spec, Refs} = SchemaToSpec(RRef, Module),
|
|
{Spec, Refs} = SchemaToSpec(RRef, Module),
|
|
|
Content = content(Spec),
|
|
Content = content(Spec),
|
|
|
- {Acc#{integer_to_binary(Status) => #{<<"content">> => Content}}, Refs ++ RefsAcc, Module, Options};
|
|
|
|
|
|
|
+ {Acc#{integer_to_binary(Status) =>
|
|
|
|
|
+ #{<<"content">> => Content}}, Refs ++ RefsAcc, Module, Options};
|
|
|
response(Status, Schema, {Acc, RefsAcc, Module, Options}) ->
|
|
response(Status, Schema, {Acc, RefsAcc, Module, Options}) ->
|
|
|
case hoconsc:is_schema(Schema) of
|
|
case hoconsc:is_schema(Schema) of
|
|
|
true ->
|
|
true ->
|
|
@@ -447,7 +460,8 @@ typename_to_spec("duration_ms()", _Mod) -> #{type => string, example => <<"32s">
|
|
|
typename_to_spec("percent()", _Mod) -> #{type => number, example => <<"12%">>};
|
|
typename_to_spec("percent()", _Mod) -> #{type => number, example => <<"12%">>};
|
|
|
typename_to_spec("file()", _Mod) -> #{type => string, example => <<"/path/to/file">>};
|
|
typename_to_spec("file()", _Mod) -> #{type => string, example => <<"/path/to/file">>};
|
|
|
typename_to_spec("ip_port()", _Mod) -> #{type => string, example => <<"127.0.0.1:80">>};
|
|
typename_to_spec("ip_port()", _Mod) -> #{type => string, example => <<"127.0.0.1:80">>};
|
|
|
-typename_to_spec("ip_ports()", _Mod) -> #{type => string, example => <<"127.0.0.1:80, 127.0.0.2:80">>};
|
|
|
|
|
|
|
+typename_to_spec("ip_ports()", _Mod) ->
|
|
|
|
|
+ #{type => string, example => <<"127.0.0.1:80, 127.0.0.2:80">>};
|
|
|
typename_to_spec("url()", _Mod) -> #{type => string, example => <<"http://127.0.0.1">>};
|
|
typename_to_spec("url()", _Mod) -> #{type => string, example => <<"http://127.0.0.1">>};
|
|
|
typename_to_spec("connect_timeout()", Mod) -> typename_to_spec("timeout()", Mod);
|
|
typename_to_spec("connect_timeout()", Mod) -> typename_to_spec("timeout()", Mod);
|
|
|
typename_to_spec("timeout()", _Mod) -> #{<<"oneOf">> => [#{type => string, example => infinity},
|
|
typename_to_spec("timeout()", _Mod) -> #{<<"oneOf">> => [#{type => string, example => infinity},
|
|
@@ -551,8 +565,8 @@ parse_object(PropList = [_ | _], Module, Options) when is_list(PropList) ->
|
|
|
true ->
|
|
true ->
|
|
|
HoconType = hocon_schema:field_schema(Hocon, type),
|
|
HoconType = hocon_schema:field_schema(Hocon, type),
|
|
|
Init0 = init_prop([default | ?DEFAULT_FIELDS], #{}, Hocon),
|
|
Init0 = init_prop([default | ?DEFAULT_FIELDS], #{}, Hocon),
|
|
|
- Init = trans_desc(Init0, Hocon),
|
|
|
|
|
SchemaToSpec = schema_converter(Options),
|
|
SchemaToSpec = schema_converter(Options),
|
|
|
|
|
+ Init = trans_desc(Init0, Hocon, SchemaToSpec, NameBin),
|
|
|
{Prop, Refs1} = SchemaToSpec(HoconType, Module),
|
|
{Prop, Refs1} = SchemaToSpec(HoconType, Module),
|
|
|
NewRequiredAcc =
|
|
NewRequiredAcc =
|
|
|
case is_required(Hocon) of
|
|
case is_required(Hocon) of
|