From 88d97b06ae5cd7816f4297e67e4701e4c2e8af82 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 28 Jul 2018 22:54:59 +0900 Subject: [PATCH] Support oneOf --- scripts/templating/matrix_templates/units.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/templating/matrix_templates/units.py b/scripts/templating/matrix_templates/units.py index 88f7b86c..5930b0d0 100644 --- a/scripts/templating/matrix_templates/units.py +++ b/scripts/templating/matrix_templates/units.py @@ -286,7 +286,9 @@ def get_json_schema_object_fields(obj, enforce_title=False): def process_data_type(prop, required=False, enforce_title=True): prop = inherit_parents(prop) - prop_type = prop['type'] + prop_type = prop.get('oneOf', prop.get('type', [])) + assert prop_type + tables = [] enum_desc = None is_object = False @@ -317,6 +319,15 @@ def process_data_type(prop, required=False, enforce_title=True): tables = nested["tables"] enum_desc = nested["enum_desc"] + elif isinstance(prop_type, list): + prop_title = [] + for t in prop_type: + if isinstance(t, dict): + nested = process_data_type(t) + tables.extend(nested['tables']) + prop_title.append(nested['title']) + else: + prop_title.append(t) else: prop_title = prop_type