Fix schema default for array path exprs
This commit is contained in:
+15
-2
@@ -101,7 +101,7 @@ mock_config() ->
|
||||
|
||||
mock_config(Cfg) ->
|
||||
ensure_schema_loaded(),
|
||||
store(Cfg, Mode = silent).
|
||||
store(Cfg, _Mode = silent).
|
||||
|
||||
unmock_config() ->
|
||||
gmconfig_schema_utils:clear(),
|
||||
@@ -445,7 +445,20 @@ just_schema_keys(_) ->
|
||||
schema_default(Path) when is_list(Path) ->
|
||||
schema_default(Path, schema()).
|
||||
|
||||
schema_default(Path, Schema) ->
|
||||
schema_default(Path0, Schema) ->
|
||||
%% There is a way to navigate through an array of objects
|
||||
%% essentially locating the desired object in the array, and then
|
||||
%% continuing into one of its properties. This is specified in
|
||||
%% a path exression as `{PropName, Value, ThenProp}`.
|
||||
%% If the query expects us to fall back to the schema default, then
|
||||
%% we must adapt the path accordingly.
|
||||
%%
|
||||
%% find_config([<<"system">>, <<"plugins">>,
|
||||
%% {<<"name">>, PluginName, <<"config">>} | Key],
|
||||
%% [user_config, schema_default]);
|
||||
Path = lists:flatmap(fun({_, _,P}) -> [<<"items">>, P];
|
||||
(P) -> [P]
|
||||
end, Path0),
|
||||
case schema(Path, Schema) of
|
||||
undefined -> undefined;
|
||||
{ok, Tree} ->
|
||||
|
||||
Reference in New Issue
Block a user