From 9f7e9ca9dfa7cfda81b4f12675f648dfd946aa75 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 16 Apr 2025 14:48:35 +0200 Subject: [PATCH] feat(jsonschema): add test for attrsof submodule --- lib/jsonschema/example-interface.nix | 8 ++++++++ lib/jsonschema/example-schema.json | 28 +++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/jsonschema/example-interface.nix b/lib/jsonschema/example-interface.nix index 9b7c1b9e8..fedd0d12b 100644 --- a/lib/jsonschema/example-interface.nix +++ b/lib/jsonschema/example-interface.nix @@ -40,6 +40,14 @@ albrecht = 3; }; }; + # attrs of submodule + userModules = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.submodule { + options.foo = lib.mkOption { }; + } + ); + }; # list of str kernelModules = lib.mkOption { type = lib.types.listOf lib.types.str; diff --git a/lib/jsonschema/example-schema.json b/lib/jsonschema/example-schema.json index ca2175472..6b95742a4 100644 --- a/lib/jsonschema/example-schema.json +++ b/lib/jsonschema/example-schema.json @@ -3,7 +3,7 @@ "$exportedModuleInfo": { "path": [] }, "type": "object", "additionalProperties": false, - "required": [ "services" ], + "required": ["services", "userModules"], "properties": { "name": { "$exportedModuleInfo": { "path": ["name"] }, @@ -47,6 +47,32 @@ }, "description": "Some attributes" }, + "userModules": { + "$exportedModuleInfo": { "path": ["userModules"] }, + "type": "object", + "additionalProperties": { + "$exportedModuleInfo": { "path": ["userModules", ""] }, + "additionalProperties": false, + "type": "object", + "properties": { + "foo": { + "$exportedModuleInfo": { + "path": ["userModules", "", "foo"] + }, + "type": [ + "boolean", + "integer", + "number", + "string", + "array", + "object", + "null" + ] + } + }, + "required": ["foo"] + } + }, "colour": { "$exportedModuleInfo": { "path": ["colour"] }, "default": "red",