You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the OpenAPI specification and the docs page, the default Content-Type for complex values (objects) in a multipart/form-data request should be application/json.
However, in the provided example, the address property, which is an object, does not have application/json as its Content-Type in the generated request and curl command.
Currently, it's possible to manually set encoding.address.contentType in the definition as application/json to generate the expected curl command (thanks to issue #5356 was fixed).
However, based on the OpenAPI specification, I believe type=application/json should automatically be applied even if encoding is not explicitly included in the definition.
Also bumped into this issue with a mixed multipart/form-data payload containing both files and a JSON options object. It seems that adding the encoding[fieldName].contentType fixes the CURL call, however it also causes Swagger to send a filename: "blob" in the Content-Disposition header.
This causes subsequent multipart parsing to think of options as a file rather than an object.
I think we should at least have a coherent Curl command and Execute action. There may be multiple issues at play, setting Content-Type should probably not trigger an automatic filename although it was referenced as mandatory, and we shouldn't need to set up Content-Type for complex objects in the first place.
I will try to narrow down what is happening with the fetch request :)
Q&A
Content & configuration
Example Swagger/OpenAPI definition:
Swagger-UI configuration options:
Describe the bug you're encountering
According to the OpenAPI specification and the docs page, the default
Content-Type
for complex values (objects) in amultipart/form-data
request should beapplication/json
.However, in the provided example, the
address
property, which is an object, does not haveapplication/json
as itsContent-Type
in the generated request and curl command.Currently, it's possible to manually set
encoding.address.contentType
in the definition asapplication/json
to generate the expected curl command (thanks to issue #5356 was fixed).However, based on the OpenAPI specification, I believe
type=application/json
should automatically be applied even ifencoding
is not explicitly included in the definition.To reproduce...
Steps to reproduce the behavior:
Expected behavior
-----------------------------306494087715324971512255078872 Content-Disposition: form-data; name="id" string -----------------------------306494087715324971512255078872 Content-Disposition: form-data; name="address" +Content-Type: application/json { "street": "string", "city": "string" } -----------------------------306494087715324971512255078872 Content-Disposition: form-data; name="profileImage"; filename="zerobyte.txt" Content-Type: text/plain -----------------------------306494087715324971512255078872--
Additional context or thoughts
Content-Type: text/plain
for theid
property is unnecessary, as it is the default value formultipart/form-data
.EDIT: this is part (maybe duplicate) of #6462
The text was updated successfully, but these errors were encountered: