I am using build from myget "4.0.0-preview-0651" to try OpenAPI 3.0 support.
I have one endpoint which is defined as List<IFormFile> fileList.
I am aware that swagger 2.0 does not support the list of Files.
However It seems that OpenAPI 3.0 has support for Multiple File Upload.
https://swagger.io/docs/specification/describing-request-body/file-upload/
Is there anything I can use to achieve that ?
@saurabhrajguru in common case required to add support for IFormFileCollection and IEnumerable<IFormFile>.
I need this feature too
Need to get OpenAPi 3.0 support in place first as 2.0 does not support multiple file uploads. The 3.0 support is in work
@domaindrivendev how to do it? Can you please explain it?
So far as generating the correct Swagger/OA3 JSON, this is already supported in 5.0.0-rc2. You just have to use IFormFileCollection or IEnumerable<IFormFile> in your action signature.
With that said, the swagger-ui library (an independent project) does not fully support this yet, so you won't be able to get the "Try Out" feature working for multiple files until they add this. See https://github.com/swagger-api/swagger-ui/issues/4600 if you want to track their progress.
Is it supposed to generate the correct swagger.json if there are multiple parameters?
The signature looks like this:
[HttpPost]
public async Task<ActionResult> StartOptimizationRun(
OptimizationRunParameters parameters, IFormFileCollection modelFiles)
The generated swagger.json looks like this:
"/OptimizationRun": {
"post": {
"tags": [
"OptimizationRun"
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/OptimizationRunParameters"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
}
},
...
"OptimizationRunParameters": {
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/ModelRunInputData"
},
"modelName": {
"type": "string",
"nullable": true
},
"modelVersion": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
It's completely missing the modelFiles parameter. Is this a bug or am I doing something wrong?
Most helpful comment
@saurabhrajguru in common case required to add support for
IFormFileCollectionandIEnumerable<IFormFile>.I need this feature too