20
20
def create (specs : openapi .Spec ) -> List [web .RouteDef ]:
21
21
# TODO: consider the case in which server creates routes for both v0 and v1!!!
22
22
# TODO: should this be taken from servers instead?
23
- BASEPATH = '/v' + specs . info . version . split ( '.' )[ 0 ]
23
+ base_path = openapi . get_base_path ( specs )
24
24
25
25
log .debug ("creating %s " , __name__ )
26
26
routes = []
@@ -30,22 +30,30 @@ def create(specs: openapi.Spec) -> List[web.RouteDef]:
30
30
# auth --
31
31
path , handler = '/auth/register' , auth_handlers .register
32
32
operation_id = specs .paths [path ].operations ['post' ].operation_id
33
- routes .append ( web .post (BASEPATH + path , handler , name = operation_id ) )
33
+ routes .append ( web .post (base_path + path , handler , name = operation_id ) )
34
34
35
35
path , handler = '/auth/login' , auth_handlers .login
36
36
operation_id = specs .paths [path ].operations ['post' ].operation_id
37
- routes .append ( web .post (BASEPATH + path , handler , name = operation_id ) )
37
+ routes .append ( web .post (base_path + path , handler , name = operation_id ) )
38
38
39
39
path , handler = '/auth/logout' , auth_handlers .logout
40
40
operation_id = specs .paths [path ].operations ['get' ].operation_id
41
- routes .append ( web .get (BASEPATH + path , handler , name = operation_id ) )
41
+ routes .append ( web .get (base_path + path , handler , name = operation_id ) )
42
42
43
43
path , handler = '/auth/confirmation/{code}' , auth_handlers .email_confirmation
44
44
operation_id = specs .paths [path ].operations ['get' ].operation_id
45
- routes .append ( web .get (BASEPATH + path , handler , name = operation_id ) )
45
+ routes .append ( web .get (base_path + path , handler , name = operation_id ) )
46
46
47
47
path , handler = '/auth/change-email' , auth_handlers .change_email
48
48
operation_id = specs .paths [path ].operations ['post' ].operation_id
49
- routes .append ( web .post (BASEPATH + path , handler , name = operation_id ) )
49
+ routes .append ( web .post (base_path + path , handler , name = operation_id ) )
50
50
51
51
return routes
52
+
53
+
54
+ # alias
55
+ create_routes = create
56
+
57
+ __all__ = (
58
+ 'create_routes'
59
+ )
0 commit comments