Connexion: ResolverError: Empty module name

Created on 26 Oct 2018  路  5Comments  路  Source: zalando/connexion

Description

Trying the basic example in readme.md

Expected behaviour

Should work.

Actual behaviour

Throws exception:

ERROR:connexion.apis.abstract:Failed to add operation for GET /v1/pets
Traceback (most recent call last):
  File "d:\py\env\lib\site-packages\connexion\apis\abstract.py", line 315, in add_paths
    self.add_operation(method, path, endpoint, path_parameters)
  File "d:\py\env\lib\site-packages\connexion\apis\abstract.py", line 273, in add_operation
    **shared_args)
  File "d:\py\env\lib\site-packages\connexion\operations\swagger2.py", line 96,
in __init__
    pass_context_arg_name=pass_context_arg_name
  File "d:\py\env\lib\site-packages\connexion\operations\abstract.py", line 99,
in __init__
    self._resolution = resolver.resolve(self)
  File "d:\py\env\lib\site-packages\connexion\resolver.py", line 40, in resolve
    return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
  File "d:\py\env\lib\site-packages\connexion\resolver.py", line 66, in resolve_function_from_operation_id
    raise ResolverError(str(e), sys.exc_info())
connexion.exceptions.ResolverError: <ResolverError: Empty module name>

Steps to reproduce

On Windows 10, Python 3.6 64 bit

Additional info:

On Windows 10, Python 3.6 64 bit

Output of the commands:

  • python --version
    Python 3.6.7rc1

  • pip show connexion | grep "^Version\:"
    Version: 2.0.0rc3
    (same with 1.5.3)

Most helpful comment

Thank you, that resolves it. Perhaps the "Running it" section in the readme should be updated as there is more to it than the 4 lines of code shown there.
Many thanks!

All 5 comments

Hey @trickidicki , I'm assuming you are using https://github.com/hjacobs/connexion-example/blob/master/swagger.yaml , if not - please post the spec you are using.

My guess is that you haven't defined your handler function. You need to provide a module+function that matches the operationId in the spec.

In the case of the petstore example, you would need to define a function called get_pets in a file called app.py because the operationId is app.get_pets.

Hope that helps!

Thank you, that resolves it. Perhaps the "Running it" section in the readme should be updated as there is more to it than the 4 lines of code shown there.
Many thanks!

Glad it worked for you. Thanks for the feedback.

I think the error message should be improved. It looks like an error from within the framework, but it is an error in the combination of operationId and user-provided entry points.

I agree Flask has great error reporting if you are adding something useful to it, don't ruin the best parts of such a good framework.

Was this page helpful?
0 / 5 - 0 ratings