|
@@ -1,5 +1,6 @@
|
1
|
1
|
# coding=utf-8
|
2
|
2
|
from tracim import TracimRequest
|
|
3
|
+from tracim.extensions import hapic
|
3
|
4
|
from tracim.views.controllers import Controller
|
4
|
5
|
from pyramid.config import Configurator
|
5
|
6
|
from pyramid.exceptions import NotFound
|
|
@@ -7,13 +8,29 @@ from pyramid.exceptions import NotFound
|
7
|
8
|
|
8
|
9
|
class DefaultController(Controller):
|
9
|
10
|
|
10
|
|
- def notfound_view(self, request:TracimRequest):
|
|
11
|
+ def notfound_view(self, request: TracimRequest):
|
11
|
12
|
request.response.status = 404
|
12
|
13
|
return {}
|
13
|
14
|
|
|
15
|
+ def swagger_doc(self, request: TracimRequest):
|
|
16
|
+ return hapic.generate_doc(
|
|
17
|
+ title='Tracim v2 API',
|
|
18
|
+ description='API of Tracim v2',
|
|
19
|
+ )
|
|
20
|
+
|
14
|
21
|
def bind(self, configurator: Configurator):
|
15
|
22
|
configurator.add_view(
|
16
|
23
|
self.notfound_view,
|
17
|
24
|
renderer='json',
|
18
|
25
|
context=NotFound,
|
19
|
26
|
)
|
|
27
|
+ configurator.add_route(
|
|
28
|
+ 'swagger_doc',
|
|
29
|
+ '/swagger_doc',
|
|
30
|
+ request_method='GET',
|
|
31
|
+ )
|
|
32
|
+ configurator.add_view(
|
|
33
|
+ self.swagger_doc,
|
|
34
|
+ route_name='swagger_doc',
|
|
35
|
+ renderer='json',
|
|
36
|
+ )
|