diff --git a/openapi2jsonschema/util.py b/openapi2jsonschema/util.py index 1250f70..34270d2 100644 --- a/openapi2jsonschema/util.py +++ b/openapi2jsonschema/util.py @@ -61,12 +61,12 @@ def allow_null_optional_fields(data, parent=None, grand_parent=None, key=None): for x in v: new_v.append(allow_null_optional_fields(x, v, parent, k)) elif isinstance(v, str): - is_null = k == "type" and v == "null" + is_non_null_type = k == "type" and v != "null" has_required_fields = grand_parent and "required" in grand_parent is_required_field = ( has_required_fields and key in grand_parent["required"] ) - if not is_null and not is_required_field: + if is_non_null_type and not is_required_field: new_v = [v, "null"] new[k] = new_v return new