From a656b5e83e26e5cfd0469d602bbdf9b4677c1da9 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 20 Nov 2023 17:01:16 +0700 Subject: [PATCH] lib/jsonschema: support listOf unspecified --- lib/jsonschema/default.nix | 9 +++++++++ lib/jsonschema/test_parseOption.nix | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/jsonschema/default.nix b/lib/jsonschema/default.nix index 646200044..0872893d6 100644 --- a/lib/jsonschema/default.nix +++ b/lib/jsonschema/default.nix @@ -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 diff --git a/lib/jsonschema/test_parseOption.nix b/lib/jsonschema/test_parseOption.nix index 7adb3d660..2934dc8e4 100644 --- a/lib/jsonschema/test_parseOption.nix +++ b/lib/jsonschema/test_parseOption.nix @@ -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; };