Browse Source

Better naming and datetime for fake_api example

Guénaël Muller 6 years ago
parent
commit
f92d641ab1

+ 3 - 3
example/fake_api/bottle_api.py View File

14
     pass
14
     pass
15
 
15
 
16
 
16
 
17
-class Controllers(object):
17
+class BottleController(object):
18
     @hapic.with_api_doc()
18
     @hapic.with_api_doc()
19
     @hapic.output_body(AboutResponseSchema())
19
     @hapic.output_body(AboutResponseSchema())
20
     def about(self):
20
     def about(self):
23
         """
23
         """
24
         return {
24
         return {
25
             'version': '1.2.3',
25
             'version': '1.2.3',
26
-            'datetime': datetime.now(),
26
+            'datetime': datetime(2017, 12, 7, 10, 55, 8, 488996),
27
         }
27
         }
28
 
28
 
29
     @hapic.with_api_doc()
29
     @hapic.with_api_doc()
109
 
109
 
110
 if __name__ == "__main__":
110
 if __name__ == "__main__":
111
     app = bottle.Bottle()
111
     app = bottle.Bottle()
112
-    controllers = Controllers()
112
+    controllers = BottleController()
113
     controllers.bind(app)
113
     controllers.bind(app)
114
     hapic.set_context(hapic.ext.bottle.BottleContext(app))
114
     hapic.set_context(hapic.ext.bottle.BottleContext(app))
115
     time.sleep(1)
115
     time.sleep(1)

+ 3 - 3
example/fake_api/flask_api.py View File

14
     pass
14
     pass
15
 
15
 
16
 
16
 
17
-class Controllers(object):
17
+class FlaskController(object):
18
     @hapic.with_api_doc()
18
     @hapic.with_api_doc()
19
     @hapic.output_body(AboutResponseSchema())
19
     @hapic.output_body(AboutResponseSchema())
20
     def about(self):
20
     def about(self):
23
         """
23
         """
24
         return {
24
         return {
25
             'version': '1.2.3',
25
             'version': '1.2.3',
26
-            'datetime': datetime.now(),
26
+            'datetime': datetime(2017, 12, 7, 10, 55, 8, 488996),
27
         }
27
         }
28
 
28
 
29
     @hapic.with_api_doc()
29
     @hapic.with_api_doc()
116
 
116
 
117
 if __name__ == "__main__":
117
 if __name__ == "__main__":
118
     app = flask.Flask(__name__)
118
     app = flask.Flask(__name__)
119
-    controllers = Controllers()
119
+    controllers = FlaskController()
120
     controllers.bind(app)
120
     controllers.bind(app)
121
     hapic.set_context(hapic.ext.flask.FlaskContext(app))
121
     hapic.set_context(hapic.ext.flask.FlaskContext(app))
122
     time.sleep(1)
122
     time.sleep(1)

+ 3 - 3
example/fake_api/pyramid_api.py View File

15
     pass
15
     pass
16
 
16
 
17
 
17
 
18
-class Controllers(object):
18
+class PyramidController(object):
19
     @hapic.with_api_doc()
19
     @hapic.with_api_doc()
20
     @hapic.output_body(AboutResponseSchema())
20
     @hapic.output_body(AboutResponseSchema())
21
     def about(self, context, request):
21
     def about(self, context, request):
24
         """
24
         """
25
         return {
25
         return {
26
             'version': '1.2.3',
26
             'version': '1.2.3',
27
-            'datetime': datetime.now(),
27
+            'datetime': datetime(2017, 12, 7, 10, 55, 8, 488996),
28
         }
28
         }
29
 
29
 
30
     @hapic.with_api_doc()
30
     @hapic.with_api_doc()
119
 
119
 
120
 if __name__ == "__main__":
120
 if __name__ == "__main__":
121
     configurator = Configurator(autocommit=True)
121
     configurator = Configurator(autocommit=True)
122
-    controllers = Controllers()
122
+    controllers = PyramidController()
123
     controllers.bind(configurator)
123
     controllers.bind(configurator)
124
     hapic.set_context(hapic.ext.pyramid.PyramidContext(configurator))
124
     hapic.set_context(hapic.ext.pyramid.PyramidContext(configurator))
125
     time.sleep(1)
125
     time.sleep(1)