This piece of code is returning error on connexion.App() Call. Can someone help in checking what mistake i am making here?
Refer- https://realpython.com/flask-connexion-rest-api/#example-code
from flask import Flask, render_template
from cpswag import app
import connexion
app = connexion.App(__name__, specification_dir='./')
app.add_api('swagger.yml')
@app.route('/', methods=["GET"])
def index():
return render_template('home.html')
app.run(debug=True)
Traceback (most recent call last):
File "/Users/vikhurana/cpswag/cpswag/__init__.py", line 30, in <module>
import cpswag.controllers # NOQA pylint: disable=wrong-import-position
File "/Users/vikhurana/cpswag/cpswag/controllers/__init__.py", line 1, in <module>
from . import status, home # noqa
File "/Users/vikhurana/cpswag/cpswag/controllers/home.py", line 5, in <module>
app.add_api('swagger.yml')
File "/Library/Python/2.7/site-packages/connexion/apps/flask_app.py", line 54, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "/Library/Python/2.7/site-packages/connexion/apps/abstract.py", line 155, in add_api
options=api_options.as_dict())
File "/Library/Python/2.7/site-packages/connexion/apis/abstract.py", line 107, in __init__
self.add_paths()
File "/Library/Python/2.7/site-packages/connexion/apis/abstract.py", line 212, in add_paths
self._handle_add_operation_error(path, method, err.exc_info)
File "/Library/Python/2.7/site-packages/connexion/apis/abstract.py", line 226, in _handle_add_operation_error
six.reraise(*exc_info)
File "/Library/Python/2.7/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
return self.function_resolver(operation_id)
File "/Library/Python/2.7/site-packages/connexion/utils.py", line 87, in get_function_from_name
module = importlib.import_module(module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ValueError: Empty module name
Comments
Post a Comment