From 5764d9ffbcafe513a10e02d90f319ab2d53baa8b Mon Sep 17 00:00:00 2001 From: ochafik Date: Sun, 10 Mar 2024 15:33:59 +0000 Subject: [PATCH] Update json-schema-to-grammar.py --- examples/json-schema-to-grammar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/json-schema-to-grammar.py b/examples/json-schema-to-grammar.py index b76aa5a34..b53c2c29f 100755 --- a/examples/json-schema-to-grammar.py +++ b/examples/json-schema-to-grammar.py @@ -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]