Skip to content

Commit

Permalink
Fix catching too broad a set of fields
Browse files Browse the repository at this point in the history
Only need to expand type fields, not everything.
  • Loading branch information
garethr committed Aug 4, 2019
1 parent cd64cbc commit 0f8e7c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openapi2jsonschema/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f8e7c6

Please sign in to comment.