falcon-apispec
falcon-apispec copied to clipboard
TypeError: unhashable type
Hi,
when I pass my Falcon resource to apispec I got this error:
loginResource = LoginResource(user_service)
deviceResource = DeviceResource()
api.add_route('/api/login', loginResource)
api.add_route('/api/devices', deviceResource)
# Create an APISpec
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from falcon_apispec import FalconPlugin
spec = APISpec(
title='Swagger Backend API',
version='1.0.0',
openapi_version='2.0',
plugins=[
FalconPlugin(api),
MarshmallowPlugin(),
],
)
# pass created resource into `path` for APISpec
spec.path(resource=deviceResource)
$ python -u test.py
Traceback (most recent call last):
File "test.py", line 214, in <module>
spec.path(resource=deviceResource)
File "C:\Work\Analytics\git\test\falcon-test\.venv\lib\site-packages\apispec\core.py", line 347, in path
path=path, operations=operations, parameters=parameters, **kwargs
File "C:\Work\Analytics\git\test\falcon-test\.venv\lib\site-packages\falcon_apispec\falcon_plugin.py", line 30, in path_helper
resource_uri_mapping = self._generate_resource_uri_mapping(self._app)
File "C:\Work\Analytics\git\test\falcon-test\.venv\lib\site-packages\falcon_apispec\falcon_plugin.py", line 23, in _generate_resource_uri_mapping
mapping[resource] = uri
TypeError: unhashable type: 'LoginResource'
which is not on the resource I have added... Any idea ?
Thanks!
What version of falcon-apispec and apispec are you using?
$ pip freeze
apispec==2.0.2
Beaker==1.10.1
falcon==2.0.0
falcon-apispec==0.3.0
falcon-auth==2.0.1
falcon-middleware-beaker==0.0.1
falcon-policy==0.2.0
gunicorn==19.9.0
marshmallow==2.19.5
mohawk==1.0.0
PyJWT==1.7.1
PyYAML==5.1.1
six==1.12.0
Yapsy==1.12.0
did it help ?
Sorry for the delay, will be taking a look at this tonight or tomorrow night.
@shazz Could you share the LoginResource
you are using? Not sure how your __init__
works.