Update json-schema-to-grammar.py

This commit is contained in:
ochafik 2024-03-10 15:33:59 +00:00
parent ee492c9e4d
commit 5764d9ffbc

View file

@ -326,7 +326,8 @@ class SchemaConverter:
# "required": ["bar"]
# }
if 'anyOf' in prop_schema and any(s.get('type') == 'null' for s in prop_schema['anyOf']):
required.remove(prop_name)
if prop_name in required:
required.remove(prop_name)
alts = [s for s in prop_schema['anyOf'] if s.get('type') != 'null']
if len(alts) == 1:
prop_schema = alts[0]