rabiaasif
rabiaasif

Reputation: 312

Resty Resolver issue Python

I was following a tutorial: https://medium.com/@ssola/building-microservices-with-python-part-i-5240a8dcc2fb

from connexion.resolver import RestyResolver
import connexion

items = {
    0: {"name": "First item"}
}


def search():
    return items

if __name__ == '__main__':
    app = connexion.App(__name__, 9090, specification_dir='swagger/')
    app.add_api('my_super_app.yaml', resolver=RestyResolver('api'))
    app.run()

I keep getting the same error: ImportError: No module named items Does any one know how to resolve this error? I pip installed all the dependencies

Here is api.itmes

items = {
    0: {"name": "First item"}
}


def search() -> list:
    return items

Here is my_super_app.yaml

swagger: "2.0"

info:
  title: "My first API"
  version: "1.0"

basePath: /v1.0

paths:
  /items/:
    get:
      responses:
        '200':
          description: 'Fetch a list of items'
          schema:
            type: array
            items:
              $ref: '#/definitions/Item'

definitions:
  Item:
    type: object
    properties:
      id:
        type: integer
        format: int64
      name: { type: string }

Error produced:

No handlers could be found for logger "connexion.options"
Traceback (most recent call last):
  File "/Users/rabiaasif/Documents/GitHub/MibsBackEnd/marble-project/marbles/flask/bff.py", line 15, in <module>
    app.add_api('my_super_app.yaml', resolver=RestyResolver('api'))
  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 64, in resolve_function_from_operation_id
    return self.function_resolver(operation_id)
  File "/Library/Python/2.7/site-packages/connexion/utils.py", line 99, in get_function_from_name
    raise last_import_error
ImportError: No module named items

Upvotes: 0

Views: 1456

Answers (1)

Joe Parzival
Joe Parzival

Reputation: 567

Whilst in you virtualenv, execute; pip install connexion[swagger-ui]

The above will fix your error, No handlers could be found for logger "connexion.options" at the top of your error produced.

I was having a similar issue. After I installed connexion with a bit extra (the above), it had solved other errors I had.

I found this in the README of bitshares-explorer-api

Upvotes: 1

Related Questions