I am using swagger hub to create this API; but it doesn't support multi files in the UI so I am unsure if I am doing this right
My goal is to have the following
item:{Json describe the item}
images[] = images for item posted as an array
titles[] = Parallel array to images that has the title for image
alt_texts[] = Parallel array to images that has the alt text for image
This has to be multipart since it is files; but am unsure if I setup the structure correctly.
Swagger/Open API Code
post:
summary: Add a new item to the store
description: ''
operationId: addItem
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/NewItemWithImage'
description: Item object that needs to be added to the store
required: true
NewItemWithImage:
type: object
properties:
item:
$ref: '#/components/schemas/NewItem'
images[]:
type: array
items:
type: string
format: binary
titles[]:
type: array
items:
type: string
alt_texts[]:
type: array
items:
type: string
variation_ids[]:
type: array
items:
type: string
required:
- item
According to File Upload section in OpenAPI 3 specification:
File Upload
Multiple File Upload
You current definition corresponds to the specification precisely:
The code for swagger-ui is failing as of today in curlify.js
curlify.js is not taking the array into account and is sending:
curl -X POST "http://localhost:9122/upload-all" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "my-attachment=[object File],[object File]"
and not something like:
curl -X POST "https://foo/v1/api/upload/" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "myfile=@bla;type=application/zip" -F "myfile=@foo;type=application/zip"