|
@@ -5,32 +5,13 @@ from http import HTTPStatus
|
5
|
5
|
import bottle
|
6
|
6
|
import time
|
7
|
7
|
import yaml
|
8
|
|
-from beaker.middleware import SessionMiddleware
|
9
|
8
|
|
10
|
9
|
import hapic
|
|
10
|
+from hapic.ext.bottle.context import BottleContext
|
11
|
11
|
from example import HelloResponseSchema, HelloPathSchema, HelloJsonSchema, \
|
12
|
12
|
ErrorResponseSchema, HelloQuerySchema, HelloFileSchema
|
13
|
13
|
from hapic.data import HapicData
|
14
|
14
|
|
15
|
|
-# hapic.global_exception_handler(UnAuthExc, StandardErrorSchema)
|
16
|
|
-# hapic.global_exception_handler(UnAuthExc2, StandardErrorSchema)
|
17
|
|
-# hapic.global_exception_handler(UnAuthExc3, StandardErrorSchema)
|
18
|
|
-# bottle.default_app.push(app)
|
19
|
|
-
|
20
|
|
-# session_opts = {
|
21
|
|
-# 'session.type': 'file',
|
22
|
|
-# 'session.data_dir': '/tmp',
|
23
|
|
-# 'session.cookie_expires': 3600,
|
24
|
|
-# 'session.auto': True
|
25
|
|
-# }
|
26
|
|
-# session_middleware = SessionMiddleware(
|
27
|
|
-# app,
|
28
|
|
-# session_opts,
|
29
|
|
-# environ_key='beaker.session',
|
30
|
|
-# key='beaker.session.id',
|
31
|
|
-# )
|
32
|
|
-# app = session_middleware.wrap_app
|
33
|
|
-
|
34
|
15
|
|
35
|
16
|
def bob(f):
|
36
|
17
|
def boby(*args, **kwargs):
|
|
@@ -113,20 +94,11 @@ app = bottle.Bottle()
|
113
|
94
|
controllers = Controllers()
|
114
|
95
|
controllers.bind(app)
|
115
|
96
|
|
116
|
|
-hapic.set_context(hapic.ext.bottle.BottleContext(app))
|
117
|
|
-
|
118
|
|
-time.sleep(1)
|
119
|
|
-s = hapic.generate_doc()
|
120
|
|
-ss = json.loads(json.dumps(s))
|
121
|
|
-for path in ss['paths']:
|
122
|
|
- for method in ss['paths'][path]:
|
123
|
|
- for response_code in ss['paths'][path][method]['responses']:
|
124
|
|
- ss['paths'][path][method]['responses'][int(response_code)] = ss['paths'][path][method]['responses'][response_code]
|
125
|
|
- del ss['paths'][path][method]['responses'][int(response_code)]
|
126
|
|
-print(yaml.dump(ss, default_flow_style=False))
|
127
|
|
-time.sleep(1)
|
128
|
|
-
|
|
97
|
+hapic.set_context(BottleContext(app))
|
129
|
98
|
|
130
|
|
-#print(json.dumps(hapic.generate_doc()))
|
|
99
|
+print(yaml.dump(
|
|
100
|
+ json.loads(json.dumps(hapic.generate_doc())),
|
|
101
|
+ default_flow_style=False,
|
|
102
|
+))
|
131
|
103
|
|
132
|
104
|
app.run(host='localhost', port=8080, debug=True)
|