3
3
import inspect
4
4
import functools
5
5
import re
6
- import flask_restful
7
6
from flask_restful_swagger import registry , registered , api_spec_endpoint
8
7
from flask_restful_swagger import html
9
8
@@ -106,8 +105,8 @@ def extract_operations(resource, path_arguments=[]):
106
105
if '__swagger_attr' in method_impl .__dict__ :
107
106
# This method was annotated with @swagger.operation
108
107
decorators = method_impl .__dict__ ['__swagger_attr' ]
109
- for att_name , att_value in decorators .items ():
110
- if isinstance (att_value , (basestring , int , list )):
108
+ for att_name , att_value in list ( decorators .items () ):
109
+ if isinstance (att_value , (str , int , list )):
111
110
if att_name == 'parameters' :
112
111
op ['parameters' ] = merge_parameter_list (op ['parameters' ], att_value )
113
112
else :
@@ -119,7 +118,7 @@ def extract_operations(resource, path_arguments=[]):
119
118
120
119
def merge_parameter_list (base , override ):
121
120
base = list (base )
122
- names = map ( lambda x : x ['name' ], base )
121
+ names = [ x ['name' ] for x in base ]
123
122
for o in override :
124
123
if o ['name' ] in names :
125
124
for n , i in enumerate (base ):
@@ -192,7 +191,7 @@ def add_model(model_class):
192
191
# of this attribute
193
192
properties = model ['properties' ] = {}
194
193
nested = model_class .nested () if isinstance (model_class , _Nested ) else {}
195
- for field_name , field_type in model_class .resource_fields .iteritems ( ):
194
+ for field_name , field_type in list ( model_class .resource_fields .items () ):
196
195
nested_type = nested [field_name ] if field_name in nested else None
197
196
properties [field_name ] = deduce_swagger_type (field_type , nested_type )
198
197
elif '__init__' in dir (model_class ):
@@ -206,7 +205,7 @@ def add_model(model_class):
206
205
defaults = {}
207
206
required = model ['required' ] = []
208
207
if argspec .defaults :
209
- defaults = zip (argspec .args [- len (argspec .defaults ):], argspec .defaults )
208
+ defaults = list ( zip (argspec .args [- len (argspec .defaults ):], argspec .defaults ) )
210
209
properties = model ['properties' ] = {}
211
210
for arg in argspec .args [:- len (defaults )]:
212
211
required .append (arg )
@@ -223,7 +222,7 @@ def deduce_swagger_type(python_type_or_object, nested_type=None):
223
222
predicate = issubclass
224
223
else :
225
224
predicate = isinstance
226
- if predicate (python_type_or_object , (basestring ,
225
+ if predicate (python_type_or_object , (str ,
227
226
fields .String ,
228
227
fields .FormattedString ,
229
228
fields .Url ,
@@ -258,7 +257,7 @@ def deduce_swagger_type_flat(python_type_or_object, nested_type=None):
258
257
predicate = issubclass
259
258
else :
260
259
predicate = isinstance
261
- if predicate (python_type_or_object , (basestring ,
260
+ if predicate (python_type_or_object , (str ,
262
261
fields .String ,
263
262
fields .FormattedString ,
264
263
fields .Url )):
@@ -312,4 +311,4 @@ def split_arg(arg):
312
311
'dataType' : spl [0 ],
313
312
'paramType' : 'path' }
314
313
315
- return map (split_arg , args )
314
+ return list ( map (split_arg , args ) )
0 commit comments