Skip to content

Commit f3388f0

Browse files
committed
Add script to output JSON Schema for gen YAML
1 parent f9b4423 commit f3388f0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/json_schema.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
import json
3+
import sys
4+
5+
from robotpy_build.config.autowrap_yml import AutowrapConfigYaml
6+
7+
schema = AutowrapConfigYaml.schema()
8+
nullable_types = (
9+
"PropData",
10+
"ClassData",
11+
"EnumData",
12+
"FunctionData",
13+
)
14+
15+
for name, definition in schema["definitions"].items():
16+
if (
17+
name in nullable_types
18+
and definition["type"] == "object"
19+
and "default" not in definition
20+
):
21+
definition["type"] = ["object", "null"]
22+
23+
json.dump(schema, sys.stdout, indent="\t")

0 commit comments

Comments
 (0)