Skip to content

TypeError: unhashable type #12

@shazz

Description

@shazz

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!

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions