File tree 4 files changed +19
-4
lines changed
4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ What’s new?
110
110
-----------
111
111
112
112
113
+ Version 1.4.4
114
+ ~~~~~~~~~~~~~
115
+
116
+ - Fix path parsing with groups (skip + warning) [issue-58](https://github.com/mrk-andreev/tornado-swagger/issues/58)
117
+
113
118
Version 1.4.3
114
119
~~~~~~~~~~~~~
115
120
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ max-args=5
40
40
max-attributes =10
41
41
max-bool-expr =5
42
42
max-module-lines =500
43
- max-nested-blocks =2
43
+ max-nested-blocks =3
44
44
max-public-methods =30
45
45
max-returns =5
46
46
max-statements =30
Original file line number Diff line number Diff line change 1
- __version__ = "1.4.3 "
1
+ __version__ = "1.4.4 "
Original file line number Diff line number Diff line change 5
5
import os
6
6
import re
7
7
import typing
8
+ import warnings
8
9
9
10
import tornado .web
10
11
import yaml
@@ -89,8 +90,13 @@ def _format_handler_path(route, method):
89
90
brackets_regex = re .compile (r"\(.*?\)" )
90
91
parameters = _extract_parameters_names (route .target , route .regex .groups , method )
91
92
route_pattern = route .regex .pattern
93
+ brackets = brackets_regex .findall (route_pattern )
92
94
93
- for i , entity in enumerate (brackets_regex .findall (route_pattern )):
95
+ if len (brackets ) != len (parameters ):
96
+ warnings .warn ("Illegal route. route.regex.groups does not match all parameters. Route = " + str (route ))
97
+ return None
98
+
99
+ for i , entity in enumerate (brackets ):
94
100
route_pattern = route_pattern .replace (entity , "{%s}" % parameters [i ], 1 )
95
101
96
102
return route_pattern [:- 1 ]
@@ -121,7 +127,11 @@ def _extract_paths(routes):
121
127
122
128
for route in routes :
123
129
for method_name , method_description in _build_doc_from_func_doc (route .target ).items ():
124
- paths [_format_handler_path (route , method_name )].update ({method_name : method_description })
130
+ path_handler = _format_handler_path (route , method_name )
131
+ if path_handler is None :
132
+ continue
133
+
134
+ paths [path_handler ].update ({method_name : method_description })
125
135
126
136
return paths
127
137
You can’t perform that action at this time.
0 commit comments