1- from typing import Sequence , Union
1+ from typing import Sequence
22
33from apispec import APISpec
4- from starlette .routing import Route , Mount
4+ from starlette .routing import BaseRoute , Mount , Route
55
66from .operation import setup_route_operations
77from .utils import convert_path
88
99__all__ = ('setup_routes' ,)
1010
1111
12- def setup_routes (routes : Sequence [Union [ Route , Mount ] ],
12+ def setup_routes (routes : Sequence [BaseRoute ],
1313 spec : APISpec , version : int = 2 ,
1414 add_head_methods : bool = False ,
1515 path : str = '' ):
@@ -18,14 +18,15 @@ def setup_routes(routes: Sequence[Union[Route, Mount]],
1818 setup_routes (route .routes , spec , version = version , add_head_methods = add_head_methods ,
1919 path = f'{ path } { route .path } ' )
2020 continue
21- elif isinstance (route , Route ) and not route .include_in_schema :
22- continue
21+ elif isinstance (route , Route ):
22+ if not route .include_in_schema :
23+ continue
2324
24- endpoint = getattr (route .endpoint , '__endpoint__' , None )
25- if endpoint is None :
26- continue
25+ endpoint = getattr (route .endpoint , '__endpoint__' , None )
26+ if endpoint is None :
27+ continue
2728
28- operations = setup_route_operations (route , endpoint , version = version ,
29- add_head_methods = add_head_methods )
30- route_path = f'{ path } { route .path } '
31- spec .path (convert_path (route_path ), operations = operations )
29+ operations = setup_route_operations (route , endpoint , version = version ,
30+ add_head_methods = add_head_methods )
31+ route_path = f'{ path } { route .path } '
32+ spec .path (convert_path (route_path ), operations = operations )
0 commit comments