Fixed multipart support for array type request body properties #1485
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have the very strong impression that request body properties of type 'array' in multipart requests were serialized wrong. For such a property a single part was created with a string representation of the array.
I fixed that so that now multiple parts with the same part name (the key of the array property) are created instead which contain the respective element's content.
Description
In src/execute/oas3/build-request.js I extracted the current transformation of request body root properties in a method and repeated the procedure for the elements of array type properties. I made sure that this happens only once - so arrays that are contained by another array are transformed like before - i.e. converted to a string.
In src/http.js I added special handling for arrays so that there won't be now a single part for the array but multiple parts for each array element all having the same name: the key of the array property.
Motivation and Context
Similar like in issue #1426 I wasn't able to send a request containing an array with multiple files to our server. Soon I found out that this is a general issue with array type properties.
I already created a question in the SmartBear community forum without getting an answer but it documents the issue very well:
https://community.smartbear.com/t5/Swagger-Open-Source-Tools/Can-Swagger-UI-for-Openapi-v3-handle-arrays-in-multipart/td-p/193648
How Has This Been Tested?
Sorry I have no idea how to test this but if you help me to set up an environment I will test it gladly.
Also please note that I am a java developer and don't know much about node.js.
Screenshots (if appropriate):
Types of changes
package.json
)Checklist:
I am unsure about all of these but happy to help if you tell me how.