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

Proposal: always return an array for response element where maxOccurs > 1 #268

Closed
LoneRifle opened this issue Mar 4, 2020 · 3 comments · Fixed by #269
Closed

Proposal: always return an array for response element where maxOccurs > 1 #268

LoneRifle opened this issue Mar 4, 2020 · 3 comments · Fixed by #269

Comments

@LoneRifle
Copy link
Contributor

LoneRifle commented Mar 4, 2020

Currently, strong-soap inherits node-soap's behaviour of returning the following for a given element defined as:

<xs:sequence>
  <xs:element maxOccurs="(greater than 1)" />
</xs:sequence>

this behaviour returns such an element as an object if it occurs once, or an array of objects if more than once. This complicates the handling of the response, as we now have to determine whether the element being returned is a single object or an array of objects.

Given the definition of such elements, we already expect the number of occurrences to be greater than 1. I hence propose that strong-soap should always return an array of objects for such elements, so that response handlers can be simplified.

Desired behaviour can be inferred from vpulim/node-soap#1100

@deepakrkris
Copy link
Contributor

@LoneRifle the client can always make necessary checks to see if a returned element is an array. So why force to return an array always ? this could break existing clients.

@LoneRifle
Copy link
Contributor Author

LoneRifle commented Mar 12, 2020

How would this break existing clients? Those clients would already embed logic to receive and handle either a single object or an array of objects due to the arguably inconsistent nature of what is being returned. I am unsure why a client would break trying to handle a one-item array.

Also, the point is not whether the client can make necessary checks, but whether it should. As noted in opening post, the goal of this issue is to allow response handlers to be simplified. Not doing so already violates the Principle of Least Surprise.

@deepakrkris
Copy link
Contributor

@raymondfeng can you validate this requirement and the associated PR. They look good to me.

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

Successfully merging a pull request may close this issue.

3 participants