@@ -147,8 +147,8 @@ def action(methods=None, detail=None, url_path=None, url_name=None, **kwargs):
147147 def decorator (func ):
148148 func .bind_to_methods = methods
149149 func .detail = detail
150- func .url_path = url_path or func .__name__
151- func .url_name = url_name or func .__name__ .replace ('_' , '-' )
150+ func .url_path = url_path if url_path else func .__name__
151+ func .url_name = url_name if url_name else func .__name__ .replace ('_' , '-' )
152152 func .kwargs = kwargs
153153 return func
154154 return decorator
@@ -163,7 +163,13 @@ def detail_route(methods=None, **kwargs):
163163 "`action`, which accepts a `detail` bool. Use `@action(detail=True)` instead." ,
164164 PendingDeprecationWarning , stacklevel = 2
165165 )
166- return action (methods , detail = True , ** kwargs )
166+
167+ def decorator (func ):
168+ func = action (methods , detail = True , ** kwargs )(func )
169+ if 'url_name' not in kwargs :
170+ func .url_name = func .url_path .replace ('_' , '-' )
171+ return func
172+ return decorator
167173
168174
169175def list_route (methods = None , ** kwargs ):
@@ -175,4 +181,10 @@ def list_route(methods=None, **kwargs):
175181 "`action`, which accepts a `detail` bool. Use `@action(detail=False)` instead." ,
176182 PendingDeprecationWarning , stacklevel = 2
177183 )
178- return action (methods , detail = False , ** kwargs )
184+
185+ def decorator (func ):
186+ func = action (methods , detail = False , ** kwargs )(func )
187+ if 'url_name' not in kwargs :
188+ func .url_name = func .url_path .replace ('_' , '-' )
189+ return func
190+ return decorator
0 commit comments