Skip to content

Commit 558678b

Browse files
committed
Merge branch 'v0.1.14'
2 parents f41f957 + a190f8d commit 558678b

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Many thanks to Tom Christie & all the contributors who have developed [Django RE
121121
* Darren Thompson (@WhiteDawn)
122122
* Lukasz Balcerzak (@lukaszb)
123123
* David Newgas (@davidn)
124+
* Bozidar Benko (@bbenko)
124125

125126

126127
### Django REST Framework Docs contributors:
@@ -132,6 +133,9 @@ Many thanks to Tom Christie & all the contributors who have developed [Django RE
132133

133134
## Release Notes:
134135

136+
### v0.1.14 (March 7, 2014)
137+
* Fixed resource name truncation bug
138+
135139
### v0.1.13 (Feb 25, 2014)
136140
* Fixed grouping bug
137141

147 KB
Binary file not shown.

rest_framework_swagger/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '0.1.13'
1+
VERSION = '0.1.14'
22

33
DEFAULT_SWAGGER_SETTINGS = {
44
'exclude_namespaces': [],

rest_framework_swagger/tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ def test_flatten_url_tree_url_import(self):
7878

7979
self.assertEqual(len(self.url_patterns), len(apis))
8080

81+
def test_resources_starting_with_letters_from_base_path(self):
82+
base_path = r'api/'
83+
url_patterns = patterns('',
84+
url(r'test', MockApiView.as_view(), name='a test view'),
85+
url(r'pai_test', MockApiView.as_view(), name='start with letters a, p, i'),
86+
)
87+
urls = patterns('', url(base_path, include(url_patterns)))
88+
urlparser = UrlParser()
89+
apis = urlparser.get_apis(urls)
90+
resources = urlparser.get_top_level_apis(apis)
91+
self.assertEqual(set(resources), set([base_path + url_pattern.regex.pattern for url_pattern in url_patterns]))
92+
8193
def test_flatten_url_tree_with_filter(self):
8294
urlparser = UrlParser()
8395
apis = urlparser.get_apis(self.url_patterns, filter_path="a-view")

rest_framework_swagger/urlparser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def __filter_top_level_apis__(self, root_paths):
7070
filtered_paths = set()
7171
base_path = self.__get_base_path__(root_paths)
7272
for path in root_paths:
73-
resource = path.lstrip(base_path).split('/')[0]
73+
if path.startswith(base_path):
74+
path = path[len(base_path):]
75+
resource = path.split('/')[0]
7476
filtered_paths.add(base_path + resource)
7577

7678
return list(filtered_paths)

0 commit comments

Comments
 (0)