Can Swagger UI for Openapi v3 handle arrays in multipart requests?
I have the following Openapi document:
{
"info": {
"description": "This document shows strange behavior in swagger ui",
"title": "This document shows a strange behavior in swagger ui",
"version": "0.0.0"
},
"openapi": "3.0.0",
"paths": {
"/post": {
"post": {
"description": "Upload multiple files",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"properties": {
"inputResources": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}
}
},
"description": "Multipart body to upload files"
}
}
},
},
"servers": [
{
"url": "https://httpbin.org"
}
]
}I want to display it with Swagger UI so I created the following HTML page:
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
url: "path/to/above/document",
validatorUrl : null,
dom_id: '#swagger-ui',
deepLinking: true,
})
window.ui = ui
}
</script>
<div id="swagger-ui"></div>I get a nice display of my request
However when I execute it the following multipart body is sent:
------WebKitFormBoundaryzRaOvYA1aX8T4BXu Content-Disposition: form-data; name="inputResources" ewrr,eeee ------WebKitFormBoundaryzRaOvYA1aX8T4BXu--
As you see the strings are just comma-separated which is not a valid way to encode an array of strings in a multipart body. I would expect a part for each string element to be created like that:
------WebKitFormBoundaryzRaOvYA1aX8T4BXu Content-Disposition: form-data; name="inputResources" ewrr ------WebKitFormBoundaryzRaOvYA1aX8T4BXu Content-Disposition: form-data; name="inputResources" eeee ------WebKitFormBoundaryzRaOvYA1aX8T4BXu--
Even worse when I change the format of the inputResources property to binary to send files instead.
"inputResources": {
"items": {
"format": "binary",
"type": "string"
},
"type": "array"
}This changes the multipart body to the following:
------WebKitFormBoundary5OvyKi6BDAuPKnFm Content-Disposition: form-data; name="inputResources" [object File],[object File] ------WebKitFormBoundary5OvyKi6BDAuPKnFm--
Again I would have expected two parts with the respective file's binary content.
Am I assuming correctly that Swagger UI simply does not support arrays yet in multipart request bodies? Or did I do something wrong?
Kind regards,
Neidhart