OAS 3: Support for uploading an array of files in multipart requests
See original GitHub issueSwagger UI 3.16.0 added support for binary file upload using multipart requests. It works if a multipart request uses files as specific named fields, but doesn’t work if the request uses an array of files.
Q&A (please complete the following information)
- OS: Windows 7
- Browser: Chrome 66
- Method of installation: http://petstore.swagger.io, also using a local copy of Editor.
- Swagger-UI version: 3.16.0
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
This spec is based on an example from the OpenAPI 3.0.1 Specification:
openapi: 3.0.1
info:
title: Multiple file upload test
version: 0.0.0
servers:
- url: http://httpbin.org
paths:
/post:
post:
requestBody:
content:
multipart/form-data:
# This works:
# schema:
# type: object
# properties:
# upload:
# type: string
# format: binary
# This doesn't work:
schema:
type: object
properties:
# The property name 'file' will be used for all files.
file:
type: array
items:
type: string
format: binary
responses:
'200':
description: OK
Is your feature request related to a problem?
Yes, clicking “try it out” shows “😱 Could not render this component, see the console.” The console errors are:
TypeError: Cannot read property 'inferSchema' of undefined
at t.value (swagger-ui.js:1)
at t.render (swagger-ui.js:1)
at u._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:796)
at u._renderValidatedComponent (ReactCompositeComponent.js:819)
at u.performInitialMount (ReactCompositeComponent.js:359)
at u.mountComponent (ReactCompositeComponent.js:255)
at Object.mountComponent (ReactReconciler.js:43)
at u.performInitialMount (ReactCompositeComponent.js:368)
at u.mountComponent (ReactCompositeComponent.js:255)
at Object.mountComponent (ReactReconciler.js:43)
TypeError: Cannot read property 'inferSchema' of undefined
at t.value (swagger-ui.js:1)
at t.render (swagger-ui.js:1)
at u._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:796)
at u._renderValidatedComponent (ReactCompositeComponent.js:819)
at u._updateRenderedComponent (ReactCompositeComponent.js:743)
at u._performComponentUpdate (ReactCompositeComponent.js:721)
at updateComponent (ReactCompositeComponent.js:642)
at u.receiveComponent (ReactCompositeComponent.js:544)
at Object.receiveComponent (ReactReconciler.js:122)
at u._updateRenderedComponent (ReactCompositeComponent.js:751)
Describe the solution you’d like
Clicking “try it out” presents a form where we can upload multiple files.
Describe alternatives you’ve considered
N/a
Additional context
This is (sort of) related to #3641 “OAS 3.0 Support Backlog”.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:83
- Comments:40 (10 by maintainers)
Top Results From Across the Web
Multipart Requests - Swagger
OAS 3 This guide is for OpenAPI 3.0. ... File uploads typically use the multipart/form-data media type, ... Primitive or array of primitives,...
Read more >Uploading an array of MultipartFile objects using Swagger-UI ...
1. You need Springfox 3.0 or springdoc-openapi to upload arrays of files - these versions generate OpenAPI 3.0 definitions (where file arrays ......
Read more >File Upload via Swagger - codeburst
The Swagger UI generates a file input field array which allows us to add or remove files before sending the request. UPDATE 06/19/2020:...
Read more >File Upload via Multipart Requests - API Microgateway 310
The following example shows how to upload a file via multipart request in OAS3. If you are using an OAS2 API definition, please...
Read more >OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, ... for File Uploads; 4.7.14.4 Support for x-www-form-urlencoded Request Bodies ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any news??? The same problem for me
@cedric-c84-eu It looks like file array upload is not implemented yet. The file inputs are displayed now, but the actual request contains the string
[object File]
instead of the file contents.