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

[#935] supporting application/json within multipart/form-data request body #980

Merged

Conversation

ddurham2
Copy link
Contributor

adding support to automatically decode json when a multipart/form-data request body contains a field with an application/json content-type

Fixes #935.

Changes proposed in this pull request:

Fills in a decode step where there's already a TODO (I think) saying it needs to be done for a variety of types.

…ultipart/form-data contains a field with an application/json content-type
@fffan64
Copy link

fffan64 commented Jul 4, 2019

It solves my issue, any idea when it will be merged ?
Thank you :)

@@ -174,6 +175,8 @@ def resolve_form(self, form_data):
self._resolve_param_duplicates(form_data[k], encoding, 'form')
if defn and defn["type"] == "array":
form_data[k] = self._split(form_data[k], encoding, 'form')
elif encoding.get('contentType', None) == 'application/json':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would empty string be safer here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't change that much for me, it is just the default val

@fffan64
Copy link

fffan64 commented Jul 9, 2019

adding support to automatically decode json when a multipart/form-data request body contains a field with an application/json content-type

Fixes #935.

Changes proposed in this pull request:

Fills in a decode step where there's already a TODO (I think) saying it needs to be done for a variety of types.

I forked your modif because i need it in one of my project quickly, thank you

@zhrkevin
Copy link

zhrkevin commented Aug 8, 2019

import json
if encoding.get('contentType', None) == "application/json":
    try:
        form_data[k] = json.loads(form_data[k])
    except Exception:
        pass

How do you feel about this?

ddurham2 and others added 3 commits August 8, 2019 08:56
Co-Authored-By: Tomasz Trębski <kornicameister@gmail.com>
accepting other non-standard json content types too

Co-Authored-By: Tomasz Trębski <kornicameister@gmail.com>
@kornicameister
Copy link
Contributor

@zhrkevin sorry for late response. It seems to me that me and connexion will part our ways. I am interested more in aiohttp support which seems to be 2nd class citizen here. That made ma start axion. If you or anyone wants to build typesafe all the way API first framework with async in mind...I will gladly accept any help 🤗

@timonbimon
Copy link

is connexion still maintained in general?

@kornicameister
Copy link
Contributor

@timonbimon honestly speaking I don't know. It's very painful to say, but all signs says that active maintenance is not so much of a priority for Zalando at the moment. Well, I am not Zalando employee, just observing the situation.

@hjacobs
Copy link
Contributor

hjacobs commented Sep 25, 2019

@timonbimon @kornicameister sorry for the late answer: I'm one of the maintainers and currently don't have Connexion much on my radar. We have an internal discussion on how we can get more people involved and help maintain Connexion.

@hjacobs
Copy link
Contributor

hjacobs commented Sep 25, 2019

In order to move forward with this PR: I would at least like to see a proper unit test.

@kornicameister
Copy link
Contributor

kornicameister commented Sep 25, 2019

@hjacobs with all due respect and I am saying this with all best intentions in my heart. I'd see connexion progress and be maintained with the love it needs. It's just that it really requires some sort of revamp in quite a few places. I have noticed that a lot of protocols a core abstract classes make are not met and it is done by either aiohttp, flask or, perhaps, even both implementations.

@ddurham2
Copy link
Contributor Author

ddurham2 commented Oct 8, 2019

@hjacobs: Unit test added. Works with new changes, fails without them.

@ddurham2
Copy link
Contributor Author

buhbump?

@crertel-axios
Copy link

bomp

@hjacobs
Copy link
Contributor

hjacobs commented Dec 3, 2019

👍

@hjacobs hjacobs merged commit 9925789 into spec-first:master Dec 3, 2019
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

Successfully merging this pull request may close these issues.

multipart/form-data content validation
7 participants