chore: add label field for schema.json.
This commit is contained in:
parent
691588ed23
commit
414d29c413
|
@ -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;
|
||||||
|
@ -551,8 +563,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
|
||||||
|
|
Loading…
Reference in New Issue