aboutsummaryrefslogtreecommitdiff
path: root/tools/swagger2html.py
diff options
context:
space:
mode:
authorSun Howwrongbum <sun@adrenosapient.com>2017-02-12 06:42:47 +0530
committerSun Howwrongbum <sun@adrenosapient.com>2017-02-12 06:42:47 +0530
commit6b75d0e26d106590494240afff586204d34e4588 (patch)
treeb9d061e5fc0a49841f41ef5afff7a998876e20a6 /tools/swagger2html.py
parentf3699c403d113b0d1a2aecea2e43b687b0719740 (diff)
downloadtrackermap-server-6b75d0e26d106590494240afff586204d34e4588.tar.gz
trackermap-server-6b75d0e26d106590494240afff586204d34e4588.tar.bz2
trackermap-server-6b75d0e26d106590494240afff586204d34e4588.zip
Update script to sort by method
Diffstat (limited to 'tools/swagger2html.py')
-rwxr-xr-xtools/swagger2html.py10
1 files changed, 8 insertions, 2 deletions
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 = '<h2><a name="paths"></a>Paths</h2>\n'
for key in sorted(sections):
md += '<h3><a name="paths_{0}"></a>{0}</h3>\n'.format(key)
- for section in sections[key]:
+ for section in sorted_by_method(sections[key]):
md += '<h4><a name="{}"></a><code>{}</code></h4>\n'.format(
section['href'], section['title']
)
@@ -256,7 +262,7 @@ def make_contents(path_section, json_data):
for key in sorted(path_section):
md += ' <li><a href="#paths_{0}">{0}</a>\n'.format(key)
md += ' <ul>\n'
- for section in path_section[key]:
+ for section in sorted_by_method(path_section[key]):
md += ' <li><a href="#{}">{}</a></li>\n'.format(
section['href'], section['title']
)