Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions swagger_to_uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
def resolve_ref(ref):
return ref.split('/')[-1]

def upcase_first_letter(s):
return s[0].upper() + s[1:]


class Property:
def __init__(self, name, type, required, example=None, description=None, default=None, enum=None, format=None,
Expand Down Expand Up @@ -83,6 +86,13 @@ def from_dict(property_name, d, required):
# type is given or must be resolved from $ref
if 'type' in type_dict:
type_str = type_dict['type']

if type_str == "string" and 'format' in type_dict and type_dict['format'].endswith("ResourceId"):
ref_type = upcase_first_letter(type_dict['format'][0 : -10])

if type_str == "array" and 'items' in type_dict and 'type' in type_dict['items'] and "string" == type_dict['items']['type'] and 'format' in type_dict['items'] and type_dict['items']['format'].endswith("ResourceId"):
ref_type = upcase_first_letter(type_dict['items']['format'][0 : -10])

elif '$ref' in type_dict:
type_str = resolve_ref(type_dict['$ref'])
ref_type = type_str
Expand Down