meta: support definitions in schema version 2

For schema version 2 of modules, the `definitions` node, as defined in
the module itself, won't be at the `options` level but at the level of
the `properties` node. Look for a `definitions` at that `properties`
level and move it to the top, if found.
This commit is contained in:
Christian Kellner 2021-05-31 16:56:24 +00:00 committed by Tom Gundersen
parent 98a82ff47e
commit a8fcda8348

View file

@ -338,7 +338,12 @@ class ModuleInfo:
# the top level schema node, since the schema inside the
# stages is written as-if they were the root node and
# so are the references
options = schema.get("properties", {}).get("options", {})
props = schema.get("properties", {})
if "definitions" in props:
schema["definitions"] = props["definitions"]
del props["definitions"]
options = props.get("options", {})
if "definitions" in options:
schema["definitions"] = options["definitions"]
del options["definitions"]