swagger-ui
swagger-ui copied to clipboard
multi-value parameters passed differently for multipart/form-data
When multipart/form-data is specified as content type, multi-value parameters are formatted as a single parameter with a strange representation (quoted and comma-separated) rather than multiple sections with the same name and raw body.
Try this parameter definition with the latest version deployed on petstore
required: true
type: array
items:
type: string
collectionFormat: multi
Related to #1657 ?
I've the same problem.
Looking at this again, the spec actually doesn't really define the behavior well when using multipart/form-data and the intended use was for application/x-www-form-urlencoded. Not really sure how to resolve this one.
The next version of the spec, OpenAPI 3.1, will support the style and explode attributes for multipart/form-data that can be used to control array serialization. I.e. whether to send the array as a single field with comma-separated values, or as multiple fields (one per value).
the spec actually doesn't really define the behavior well
What the spec says is:
Form parts with identical field names MUST NOT be coalesced.
https://tools.ietf.org/html/rfc7578#section-5.2
Multiple repeated sections is what browsers send, so maybe that should be the default.
Got the same issue. Using encoding block, I was able to solve the issue. Instead of getting -F column=value1,value2, I now get -F column=value1 -F column=value2 in generated CURL calls. Below an excerpt for people with the issue. Deduced from OpenAPI v3.1 spec https://spec.openapis.org/oas/latest.html#encoding-object-example
/search/csv:
post:
requestBody:
required: true
content:
multipart/form-data:
encoding:
column:
explode: true
result_columns:
explode: true
schema:
type: object
required: ["data"]
properties:
column:
description: "Par défaut, toutes les colonnes sont concaténées pour constituer l’adresse qui sera géocodée. On peut définir les colonnes à utiliser via ce paramètre"
type: array
items:
type: string
result_columns:
description: "Champs attendus dans la réponse"
type: array
items:
type: string
data:
description: "Le fichier doit être un CSV dont la taille ne doit pas excéder 50 Mo"
type: string
format: binary