Reputation: 121
I’m trying to send an array of objects through multipart/form-data
:
post:
summary: Creates a user
requestBody:
content:
multipart/form-data:
schema:
type: object
properties: # Request parts
id:
type: string
format: uuid
address: # <---------
type: array
items:
type: object
properties:
street:
type: string
city:
type: string
profileImage:
type: string
format: base64
But Swagger UI sends the address
array incorrectly - as {},{}
instead of [{},{}]
, that is, without the enclosing square brackets:
I even tried encoding it separately as JSON.
What am I missing, please?
Upvotes: 1
Views: 3567
Reputation: 121
i later got it to work by adding example
post:
summary: Creates a user
requestBody:
content:
multipart/form-data:
schema:
type: object
properties: # Request parts
id:
type: string
format: uuid
address:
type: array
items:
type: object
properties:
street:
type: string
city:
type: string
example:
- street: Jones Street, Manhattan
city: New York
- street: Hollywood Boulevard
city: Los Angeles
profileImage:
type: string
format: base64
my observation is just send or modify what you already have in the example, adding new ones won't be correctly formatted. that is, if you have two items in an array work with those two do not add extra items
Upvotes: 3