From 9498c9d832f370d040255876c50e70caa289bdf4 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 28 Apr 2014 16:08:33 -0300 Subject: [PATCH] fixed the api listing --- luncho/server.py | 10 ++++++---- tests/index_tests.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/luncho/server.py b/luncho/server.py index 1084878..d3752df 100644 --- a/luncho/server.py +++ b/luncho/server.py @@ -6,8 +6,6 @@ import json import hmac import datetime -from operator import itemgetter - from flask import Flask from flask import jsonify @@ -212,12 +210,16 @@ def show_api(): summary = ' '.join(line.strip() for line in summary.split('\n')) for method in rule.methods: + if method not in ['GET', 'POST', 'PUT', 'DELETE']: + # other methods are not required + continue + routes.append([ - rule.methods.upper() + ' ' + path, + method.upper() + ' ' + path, summary ]) - routes.sort(key=itemgetter(0)) + routes.sort(key=lambda url: url[0].split()[1]) return jsonify(status='OK', api=routes) diff --git a/tests/index_tests.py b/tests/index_tests.py index 5fc0f9c..c651594 100644 --- a/tests/index_tests.py +++ b/tests/index_tests.py @@ -22,7 +22,7 @@ class TestIndex(LunchoTests): self.assertJsonOk(rv) response = json.loads(rv.data) - self.assertEqual(response['api'][0][0], '/') + self.assertEqual(response['api'][0][0], 'GET /') if __name__ == '__main__': unittest.main()