JSON schema converter: make regular attrs required

This commit is contained in:
Valentin Gagarin 2025-04-04 11:15:20 +02:00 committed by Kiara Grouwstra
parent 81842f714e
commit a02f81567f
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU

View file

@ -127,7 +127,7 @@ rec {
# parse options to jsonschema properties
properties = lib.mapAttrs (_name: option: (parseOption' (path ++ [ _name ]) option)) options';
# TODO: figure out how to handle if prop.anyOf is used
isRequired = prop: !(prop ? default || prop.type or null == "object");
isRequired = prop: !(prop ? default || prop."$exportedModuleInfo".required or false);
requiredProps = lib.filterAttrs (_: prop: isRequired prop) properties;
required = lib.optionalAttrs (requiredProps != { }) { required = lib.attrNames requiredProps; };
header' = if addHeader then header else { };
@ -381,7 +381,11 @@ rec {
# return jsonschema property definition for attrs
then
default
// exposedModuleInfo
// (lib.reqursiveUpdate exposedModuleInfo {
"$exportedModuleInfo" = {
required = true;
};
})
// example
// description
// {