import connexion, os
from connexion.resolver import RestyResolver
from flask import json
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow


# Globally accessible libraries
db = SQLAlchemy()
mm = Marshmallow()


def init_app():
    """Initialize the Connexion application."""
    BASE_DIR = os.path.abspath(os.path.dirname(__file__))
    openapi_path = os.path.join(BASE_DIR, "../")
    conn_app = connexion.FlaskApp(
        __name__, specification_dir=openapi_path, options={
            "swagger_ui": True,
            "serve_spec": True
            }
        )
    conn_app.add_api("openapi.yaml", resolver=RestyResolver('run'),
                     strict_validation=True)
    # Flask app and getting into app_context
    app = conn_app.app

    # Load application config
    app.config.from_object('config.ProdConfig')
    app.json_encoder = json.JSONEncoder

    # Initialize Plugins
    db.init_app(app)
    mm.init_app(app)

    with app.app_context():
        # Include our Routes/views
        import run

        # Register Blueprints
        # app.register_blueprint(auth.auth_bp)
        # app.register_blueprint(admin.admin_bp)

        return app

[((9, 5, 9, 17), 'flask_sqlalchemy.SQLAlchemy', 'SQLAlchemy', ({}, {}), '()', False, 'from flask_sqlalchemy import SQLAlchemy\n'), ((10, 5, 10, 18), 'flask_marshmallow.Marshmallow', 'Marshmallow', ({}, {}), '()', False, 'from flask_marshmallow import Marshmallow\n'), ((16, 19, 16, 48), 'os.path.join', 'os.path.join', ({(16, 32, 16, 40): 'BASE_DIR', (16, 42, 16, 47): '"""../"""'}, {}), "(BASE_DIR, '../')", False, 'import connexion, os\n'), ((17, 15, 22, 9), 'connexion.FlaskApp', 'connexion.FlaskApp', (), '', False, 'import connexion, os\n'), ((15, 31, 15, 56), 'os.path.dirname', 'os.path.dirname', ({(15, 47, 15, 55): '__file__'}, {}), '(__file__)', False, 'import connexion, os\n'), ((23, 46, 23, 66), 'connexion.resolver.RestyResolver', 'RestyResolver', ({(23, 60, 23, 65): '"""run"""'}, {}), "('run')", False, 'from connexion.resolver import RestyResolver\n')]