lib/jsonschema: support listOf unspecified
All checks were successful
checks-impure / test (pull_request) Successful in 1m41s
checks / test (pull_request) Successful in 2m52s

This commit is contained in:
DavHau 2023-11-20 17:01:16 +07:00
parent bd7899e48a
commit e779bc2d11
2 changed files with 21 additions and 0 deletions

View File

@ -138,6 +138,15 @@ rec {
};
}
# parse list of unspecified
else if
(option.type.name == "listOf")
&& (option.type.functor.wrapped.name == "unspecified")
# return jsonschema property definition for list
then default // description // {
type = "array";
}
# parse attrsOf submodule
else if option.type.name == "attrsOf" && option.type.nestedTypes.elemType.name == "submodule"
# return jsonschema property definition for attrsOf submodule

View File

@ -115,6 +115,18 @@ in
};
};
testListOfUnspacified =
let
default = [ 1 2 3 ];
in
{
expr = slib.parseOption (evalType (lib.types.listOf lib.types.unspecified) default);
expected = {
type = "array";
inherit default description;
};
};
testAttrsOfInt =
let
default = { foo = 1; bar = 2; baz = 3; };