Open IonelLupu opened 6 years ago
I want to send to the server a request in this format(from Chrome Header/Form Data):
------WebKitFormBoundarynP2Wq5aK1GFB5j8h Content-Disposition: form-data; name="name" Hotel 1 ------WebKitFormBoundarynP2Wq5aK1GFB5j8h Content-Disposition: form-data; name="rooms[0][name]" First room ------WebKitFormBoundarynP2Wq5aK1GFB5j8h Content-Disposition: form-data; name="rooms[0][image]"; filename="img1.jpg" Content-Type: application/octet-stream <image data here> ------WebKitFormBoundarynP2Wq5aK1GFB5j8h Content-Disposition: form-data; name="rooms[1][name]" Second room ------WebKitFormBoundarynP2Wq5aK1GFB5j8h Content-Disposition: form-data; name="rooms[1][image]"; filename="img2.jpg" Content-Type: application/octet-stream <image data here> ------WebKitFormBoundarynP2Wq5aK1GFB5j8h--
OpenAPI Specification does not provide a way to define such requests.
Field names like rooms[1][name]
resemble the deepObject
serialization style, which can be applied to multipart/*
form fields in the next version of the spec, OpenAPI 3.1. However, deepObject
behavior is defined only for simple non-nested objects, but not for arrays and not for nested objects.The rooms
field in your example is an array (array of Room
), so it's not covered by what deepObject
currently supports.
This is a limitation of the OpenAPI Specification, not Swagger UI.
As for the first question
It is possible to have input fields for each element in the arrays?
see https://github.com/swagger-api/swagger-ui/issues/2771#issuecomment-288471955
@hkosova I honestly forgot what was the problem here. It has been almost two years. You can close it if you think the issues is fixed
The issue is not fixed yet. multipart/form-data
still cannot render a nested form for an array of objects. Only works with an array of strings.
Q&A (please complete the following information)
Content & configuration
Swagger/OpenAPI definition:
Swagger-UI configuration options:
Screenshots
How can we help?
As you can see in the image there are input fields for the
images
parameter but not for the rooms parameters. These are in JSON format. It is possible to have input fields for each element in the arrays? Also, I seems the data is not sent in the proper format. I want to send to the server a request in this format(from Chrome Header/Form Data):But Swagger is sending it in this format: