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

Fixed multipart support for array type request body properties #1485

Conversation

neidhart-orlich-bt
Copy link

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

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I am unsure about all of these but happy to help if you tell me how.

@neidhart-orlich-bt
Copy link
Author

Some tests seem to fail... If somebody would be so kind as to help me out set up an environment where I can run them locally I will try to understand what's going on

@tim-lai
Copy link
Contributor

tim-lai commented May 13, 2020

@neidhart-orlich-bt Thank you for your PR. I am closing this because it is superseded by PR #1527

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.

2 participants