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

support multiple content types for the same request body #1638

Closed
gfleischer-meta opened this issue Feb 15, 2023 · 1 comment
Closed

support multiple content types for the same request body #1638

gfleischer-meta opened this issue Feb 15, 2023 · 1 comment

Comments

@gfleischer-meta
Copy link

gfleischer-meta commented Feb 15, 2023

Description

connexion support for sending multiple body types for the same request body.
for example:

  • application/x-www-form-urlencoded
  • application/json

Expected behavior

Connexion accepts multiple content types for the same request

Actual behavior

will work for 'application/x-www-form-urlencoded' because it is the first content type in the request
but for 'application/json' will fail with an Erro and a warning:
WARNING this operation accepts multiple content types, using application/x-www-form-urlencoded

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2463, in wsgi_app
```     response = self.full_dispatch_request()
```   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1760, in full_dispatch_request
```     rv = self.handle_user_exception(e)
```   File "/usr/local/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
```     return cors_after_request(app.make_response(f(*args, **kwargs)))
```   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1758, in full_dispatch_request
```     rv = self.dispatch_request()
```   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1734, in dispatch_request
```     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
```   File "/usr/local/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 68, in wrapper
```     response = function(request)
```   File "/usr/local/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 149, in wrapper
```     response = function(request)
```   File "/usr/local/lib/python3.8/site-packages/connexion/decorators/validation.py", line 173, in wrapper
```     data.update(dict.fromkeys(request.files, ''))  # validator expects string..
``` AttributeError: 'bytes' object has no attribute 'update'

if the the order is switched(content type 'application/json' is first and then 'application/x-www-form-urlencoded')
it will work for 'application/json' and for 'application/x-www-form-urlencoded' it will return an empty bytes object with the warning:
WARNING this operation accepts multiple content types, using application/json

Additional info:

I saw that there was a commit to try and fix this but it was closed:
#1435

and a commit to support this issue that was merged but not tagged yet in a release:
#1588

when will this issue be fixed?
is it expected to be released soon?
thanks in advance

Steps to reproduce

a request body for example I would expect to work:

        description: example
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              x-body-name: new_tmp
              type: object
              properties:
                name:
                  type: string
                age:
                  type: integer
          application/json:
            schema:
              x-body-name: new_tmp
              type: object
              properties:
                name:
                  type: string
                age:
                  type: integer

Python 3.8.16
Connexion version: 2.14.2
@RobbeSneyders
Copy link
Member

Hi @gfleischer-meta this is indeed fixed in the PR you linked, but not yet released as this is part of a major refactoring towards version 3.0. We're done with most feature work with 3.0, now just working on expanding our test suite for the new AsyncApp, after which we'll release a first alpha version. I hope to do this in the next weeks.

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

No branches or pull requests

2 participants