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

handle deepObject and explode: true #971

Merged
merged 35 commits into from
Oct 15, 2019

Conversation

drummerwolli
Copy link
Contributor

@drummerwolli drummerwolli commented Jun 7, 2019

Fixes #970 .

Changes proposed in this pull request:

  • handle deepObject style and explode true params introduced in OAS3

@drummerwolli
Copy link
Contributor Author

drummerwolli commented Jun 7, 2019

question:

  • I'm not sure if chose the right approach here, please advise if this is how you would do it.
  • this new feature is only available in OAS3. if I correctly checked the tests, then there is currently no scenario set up for this (different results when using OAS3 vs. OAS2, see for example connexion does not parse simple reference links #967), or? since I believe there will be more things like this in the future, how would you rather handle this?

I can continue with this. but first, need to get input from the maintainers ...

@drummerwolli
Copy link
Contributor Author

@hjacobs @prawn-cake @jmcs this is the PR we talked in chat about ...

@hpdang hpdang requested review from jmcs and hjacobs June 10, 2019 09:02
Copy link
Contributor

@prawn-cake prawn-cake left a comment

Choose a reason for hiding this comment

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

Some minor comments and improvement suggestions

connexion/operations/abstract.py Outdated Show resolved Hide resolved
connexion/decorators/validation.py Outdated Show resolved Hide resolved
connexion/operations/abstract.py Outdated Show resolved Hide resolved
@dtkav
Copy link
Collaborator

dtkav commented Jun 13, 2019

It's been a while since I worked on this, but IIRC there was some part of this that needed to happen early in the request flow (maybe before schema validation?).

Have you seen this file: https://github.com/zalando/connexion/blob/master/connexion/decorators/uri_parsing.py#L149 ?

I think object-level and array-level decoding was happening in that file, and then basic type casting happens later on.
Hopefully that's more helpful than it is confusing - I'll have to sit down and re-read the code to get more insight.

@drummerwolli drummerwolli marked this pull request as ready for review June 18, 2019 18:43
@drummerwolli
Copy link
Contributor Author

@dtkav it was absolutely helping. i was wondering already why i had to implement param parsing twice. but this file was the key, now i just once disect the object 👍

converted this PR to a real one, to triger the tests

@drummerwolli
Copy link
Contributor Author

I consider this now ready4review ...

@drummerwolli drummerwolli requested a review from dtkav June 19, 2019 20:52
tests/conftest.py Outdated Show resolved Hide resolved
connexion/utils.py Outdated Show resolved Hide resolved
possible_key = groups.group(1)
param_defn = self.param_defns.get(possible_key)
if param_defn \
and param_defn.get('style', None) == 'deepObject' and param_defn.get('explode', False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

check out _resolve_parameter_duplicates(...) and _split(...)
these should get rid of the array unwrapping that you are doing in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what you mean with that. but i moved the array unnesting now to uri_parsing. would that be sufficient enough?

Copy link
Collaborator

@dtkav dtkav left a comment

Choose a reason for hiding this comment

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

Nice work! This will be a great feature to have.

I think it's getting really close! Let me know if you have questions on my feedback.

Also, it's worth noting that I can provide review, but I don't have merge permissions - at the end of the day you need to pass review from a zalando employee.

@drummerwolli
Copy link
Contributor Author

@dtkav thx a lot for the thorough review. i pushed some changes regarding your comments.

please check again @hjacobs @jmcs @dtkav @prawn-cake

connexion/utils.py Outdated Show resolved Hide resolved
description: object response
content:
application/json:
schema:
Copy link
Collaborator

@dtkav dtkav Jun 26, 2019

Choose a reason for hiding this comment

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

do you need to set allowReserved: true?
AFAICT your examples send non-percent-encoded [ ] characters nevermind this only applies to parameter values. Not sure if that's also in scope, but it would be a good feature to implement soon as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shall we create a new issue to keep track of this? for us, this won't be needed for now.

@drummerwolli drummerwolli requested review from dtkav and jmcs September 27, 2019 08:31
@drummerwolli
Copy link
Contributor Author

drummerwolli commented Oct 14, 2019

@ancelotpinto @hjacobs @dtkav @jmcs @prawn-cake can we get this reviewed and merged somehow? we've been running this already from the fork since weeks now, no problems so far.

@hjacobs
Copy link
Contributor

hjacobs commented Oct 15, 2019

👍

@hjacobs hjacobs merged commit 54e50f2 into spec-first:master Oct 15, 2019
@drummerwolli drummerwolli deleted the fix_exploded_obejcts branch October 15, 2019 17:44
@drummerwolli
Copy link
Contributor Author

thx @hjacobs

@dtkav
Copy link
Collaborator

dtkav commented Dec 17, 2019

The default setting code in the PR isn't scoped properly, so (for example) it will take query defaults and set the request.form to the query defaults.

I'll try to put up a minimal working example that shows this behavior and a fix.

@dtkav
Copy link
Collaborator

dtkav commented Dec 18, 2019

#1092 shows the bug also

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

Successfully merging this pull request may close these issues.

objects with style: deepObject and explode: true are not supported
6 participants