Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: '<lambda>' raises using the method 'register_existing_resources' #229

Closed
liza0525 opened this issue Dec 29, 2021 · 1 comment · Fixed by #233 · May be fixed by #230
Closed

KeyError: '<lambda>' raises using the method 'register_existing_resources' #229

liza0525 opened this issue Dec 29, 2021 · 1 comment · Fixed by #233 · May be fixed by #230

Comments

@liza0525
Copy link

Hi, the KeyError raises, due to Flask 2.0.x updating.

File "run.py", line 5, in <module>
    app = create_app()
  File "C:\temp_pjt\main\__init__.py", line 68, in create_app
    docs.register_existing_resources()
  File "C:\temp\flask_apispec\extension.py", line 107, in register_existing_resources
    self.register(rule, blueprint=blueprint_name)
  File "C:\temp\flask_apispec\extension.py", line 124, in register
    self._defer(self._register, target, endpoint, blueprint,
  File "C:\temp\flask_apispec\extension.py", line 72, in _defer
    bound()
  File "C:\temp\flask_apispec\extension.py", line 140, in _register
    paths = self.view_converter.convert(target, endpoint, blueprint)
  File "C:\temp\flask_apispec\apidoc.py", line 38, in convert
    rules = self.app.url_map._rules_by_endpoint[endpoint]
KeyError: '<lambda>'

In the Flask.__init__ method, 'view_func' of the endpoint 'static' has been changed from self_ref().send_static_file to lambda function.
So, target.__name__.lower()(endpoint) is <lambda>. It doesn't exist in self.app.url_map._rules_by_endpoint as a key.

Please follow up this issue.

@codectl
Copy link

codectl commented Jan 26, 2022

I solved this one by FlaskApiSpec(document_options=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants