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

It looks like connexion 1.1.6 broke compatibility with flask-injector. #469

Closed
tjhgit opened this issue Jun 16, 2017 · 10 comments
Closed

It looks like connexion 1.1.6 broke compatibility with flask-injector. #469

tjhgit opened this issue Jun 16, 2017 · 10 comments

Comments

@tjhgit
Copy link

tjhgit commented Jun 16, 2017

Description

This code https://medium.com/@ssola/building-microservices-with-python-part-i-5240a8dcc2fb section working with Flask Injector does not work.

Expected behaviour

Should work

Actual behaviour

Error message:
TypeError: search() missing 1 required positional argument: 'data_provider'

Steps to reproduce

use connexion 1.1.6 or higher in requirements.txt

Additional info:

Output of the commands:

  • python --version
    3.6

  • pip show connexion | grep "^Version\:"

@hjacobs
Copy link
Contributor

hjacobs commented Jun 16, 2017

Thanks for the information, did not know about that!

@tjhgit
Copy link
Author

tjhgit commented Jun 20, 2017

Will you be able to fix this?

@rafaelcaricio
Copy link
Collaborator

@tjhgit Are you willing to do a PR to fix this?

@jstasiak
Copy link

Hey all, I'm in the process of debugging this so might as well send a PR when I know what's going on.

@jstasiak
Copy link

Unfortunately I'm not familiar with connexion enough to create a proper automated test (required for a PR as far as I'm concerned) but I was able to verify a patch to connexion against a simple test case and it works. This is the patch:

diff --git a/connexion/decorators/parameter.py b/connexion/decorators/parameter.py
index 54734d8..906163b 100644
--- a/connexion/decorators/parameter.py
+++ b/connexion/decorators/parameter.py
@@ -142,6 +142,12 @@ def parameter_to_arg(parameters, consumes, function, pythonic_params=False):
             logger.debug("Body parameter '%s' in function arguments", body_name)
             kwargs[body_name] = request_body
 
+        for key, value in path_params.items():
+            if key not in kwargs:
+                kwargs[key] = value
+
         # Add query parameters
         query_arguments = copy.deepcopy(default_query_params)
         query_arguments.update({sanitize_param(k): v for k, v in request.query.items()})

The issue is that keyword arguments to views are silently discarded if they don't correspond to named URL placeholders which interferes with Flask-Injector because Flask-Injector uses exactly that mechanism to provide dependencies.

I hope someone can use the patch above and create a proper connexion change (if it's determined to be desired).

@andrewgrz
Copy link

I can replicate this issue in 1.1.13 as well. This issue is not present in 1.1.5

@dcarrot2
Copy link

I can replicate this on 1.1.9. Is anyone working on this? I can take a crack at it. Is it a matter of taking the patch above and writing some tests for it? (The patch works for me)

@hjacobs
Copy link
Contributor

hjacobs commented Aug 30, 2017

@dcarrot2 go ahead 😄

egalev added a commit to egalev/connexion that referenced this issue Oct 10, 2017
hjacobs pushed a commit that referenced this issue Oct 11, 2017
…eters to the handler (#526)

* Restored Flask-Injector support

* Added a unit test to verify injection works (#469)

* Changed unittest to support Python 2
@vanyakosmos
Copy link

Still have this problem with connexion v1.3

@vanyakosmos
Copy link

vanyakosmos commented Mar 27, 2018

False alert. Issue solved by specifying arguments names in binder

binder.bind(
  Normalizer,
  Normalizer(foo="bar")
)
# instead of
binder.bind(
  Normalizer,
  Normalizer("bar")
)

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

No branches or pull requests

7 participants