From f3388f0c2e67f75e4baf49993e7df49ece12b806 Mon Sep 17 00:00:00 2001 From: David Vo Date: Wed, 1 Jan 2025 13:20:29 +1100 Subject: [PATCH] Add script to output JSON Schema for gen YAML --- examples/json_schema.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 examples/json_schema.py diff --git a/examples/json_schema.py b/examples/json_schema.py new file mode 100755 index 00000000..b1b8c179 --- /dev/null +++ b/examples/json_schema.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import json +import sys + +from robotpy_build.config.autowrap_yml import AutowrapConfigYaml + +schema = AutowrapConfigYaml.schema() +nullable_types = ( + "PropData", + "ClassData", + "EnumData", + "FunctionData", +) + +for name, definition in schema["definitions"].items(): + if ( + name in nullable_types + and definition["type"] == "object" + and "default" not in definition + ): + definition["type"] = ["object", "null"] + +json.dump(schema, sys.stdout, indent="\t")