66from flask_opentracing import FlaskTracer
77
88from pyms .config .conf import get_conf
9+ from pyms .flask .app .swagger import Swagger
910from pyms .flask .healthcheck import healthcheck_blueprint
1011from pyms .logger import CustomJsonFormatter
1112from pyms .tracer .main import init_jaeger_tracer
@@ -18,6 +19,8 @@ class Microservice:
1819 def __init__ (self , service : Text , path = __file__ ):
1920 self .service = service
2021 self .path = os .path .dirname (path )
22+ self .swagger = Swagger ()
23+ self .config = get_conf (service = self .service )
2124
2225 def init_libs (self ):
2326 return self .application
@@ -29,16 +32,16 @@ def create_app(self):
2932 return the app and the database objects.
3033 :return:
3134 """
32- config = get_conf ( service = self . service )
33- app = connexion .App (__name__ , specification_dir = os .path .join (self .path , ' swagger' ))
34- app .add_api (' swagger.yaml' ,
35- arguments = {'title' : config .APP_NAME },
36- base_path = config .APPLICATION_ROOT
35+
36+ app = connexion .App (__name__ , specification_dir = os .path .join (self .path , self . swagger . path ))
37+ app .add_api (self . swagger .file ,
38+ arguments = {'title' : self . config .APP_NAME },
39+ base_path = self . config .APPLICATION_ROOT
3740 )
3841
3942 self .application = app .app
4043 self .application ._connexion_app = app
41- self .application .config .from_object (config )
44+ self .application .config .from_object (self . config )
4245 self .application .tracer = None
4346
4447 # Initialize Blueprints
@@ -74,5 +77,4 @@ def add_error_handler(self, code_or_exception, handler):
7477 :param code_or_exception: HTTP error code or exception
7578 :param handler: callback for error handler
7679 """
77-
7880 self .application ._connexion_app .add_error_handler (code_or_exception , handler )
0 commit comments