Skip to content

Commit

Permalink
fix(openapi): remove duplicate properties field
Browse files Browse the repository at this point in the history
Resolves #101
  • Loading branch information
mostaphaRoudsari authored and MingboPeng committed Apr 26, 2020
1 parent eb71eb3 commit 44122c1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions honeybee_schema/_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def get_openapi(

sorted_props.update(optional)

try:
if 'properties' in s:
s['properties'] = sorted_props
except KeyError:
else:
s['allOf'][1]['properties'] = sorted_props

tag_names.sort()
Expand Down Expand Up @@ -236,7 +236,7 @@ def get_schemas_inheritance(model_cls):
def set_inheritance(name, top_classes, schemas):
"""Set inheritance for object with a certain name."""
# this is the list of special keys that we copy in manually
copied_keys = set(['type', 'properties', 'required'])
copied_keys = set(['type', 'properties', 'required', 'additionalProperties'])
# remove the class itself
print(f'\nProcessing {name}')
top_classes = top_classes[1:]
Expand Down Expand Up @@ -322,10 +322,13 @@ def set_inheritance(name, top_classes, schemas):
except KeyError:
print(f'Found object with no type:{name}')

if 'additionalProperties' in object_dict:
data_copy['allOf'][1]['additionalProperties'] = \
object_dict['additionalProperties']

# add other items in addition to copied_keys
for key, value in schemas[name].items():
if key in copied_keys:
continue
data_copy[key] = value

return data_copy

0 comments on commit 44122c1

Please sign in to comment.