fix: empty properties as empty map so it ends up as a json object

This commit is contained in:
Stefan Strigler 2023-06-01 18:55:37 +02:00
parent e62bd63199
commit 8fdc9de9e9
1 changed files with 6 additions and 1 deletions

View File

@ -965,7 +965,7 @@ to_bin(X) ->
parse_object(PropList = [_ | _], Module, Options) when is_list(PropList) ->
{Props, Required, Refs} = parse_object_loop(PropList, Module, Options),
Object = #{<<"type">> => object, <<"properties">> => Props},
Object = #{<<"type">> => object, <<"properties">> => fix_empty_props(Props)},
case Required of
[] -> {Object, Refs};
_ -> {maps:put(required, Required, Object), Refs}
@ -1035,6 +1035,11 @@ is_hidden(Hocon) ->
is_required(Hocon) ->
hocon_schema:field_schema(Hocon, required) =:= true.
fix_empty_props([]) ->
#{};
fix_empty_props(Props) ->
Props.
content(ApiSpec) ->
content(ApiSpec, undefined).