From 6b75d0e26d106590494240afff586204d34e4588 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Sun, 12 Feb 2017 06:42:47 +0530 Subject: Update script to sort by method --- tools/swagger2html.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tools/swagger2html.py') diff --git a/tools/swagger2html.py b/tools/swagger2html.py index a3488835c..1121f04c9 100755 --- a/tools/swagger2html.py +++ b/tools/swagger2html.py @@ -224,11 +224,17 @@ def make_responses_table(responses): except KeyError as e: handleException('KeyError', e) +def sorted_by_method(section): + sorting_function = lambda x: [ 'GET', 'POST', 'PUT', 'DELETE' ].index( + x['title'].split(' ')[0] + ) + return sorted(sorted(section), key=sorting_function) + def make_paths(sections, json_data): md = '

Paths

\n' for key in sorted(sections): md += '

{0}

\n'.format(key) - for section in sections[key]: + for section in sorted_by_method(sections[key]): md += '

{}

\n'.format( section['href'], section['title'] ) @@ -256,7 +262,7 @@ def make_contents(path_section, json_data): for key in sorted(path_section): md += '
  • {0}\n'.format(key) md += '