-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Wrong input type in multi-file upload #5656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related: OAI/OpenAPI-Specification#254 |
@eduherminio Please provide a full definition and not a snippet to help test the issue. |
[HttpPost("{userId}/{id}")]
public async Task<string> UploadFiles(int userId, string id, ICollection<IFormFile> files)
{
// ...
}
[HttpPost("test")]
public async Task<string> UploadFile(IFormFile file)
{
// ....
} {
"swagger": "2.0",
"info": {
"version": "4.0.1.0",
"title": "Test_Poc API",
"description": "Test_Poc API",
"termsOfService": "Test Limited, registered in England and Wales, Company no. XXXXXXXX",
"contact": {
"name": "Test"
},
"license": {
"name": "All rights restricted"
}
},
"paths": {
"/api/File/{userId}/{id}": {
"post": {
"tags": [
"File"
],
"summary": "Uploads multiple files -> buggy",
"operationId": "UploadFiles",
"consumes": [
"multipart/form-data"
],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "userId",
"in": "path",
"description": "",
"required": true,
"type": "integer",
"format": "int32"
},
{
"name": "id",
"in": "path",
"description": "File group identifier",
"required": true,
"type": "string"
},
{
"name": "files",
"in": "formData",
"description": "",
"required": false,
"type": "array",
"items": {},
"collectionFormat": "multi",
"uniqueItems": false
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "string"
}
}
}
}
},
"/api/File/test": {
"post": {
"tags": [
"File"
],
"summary": "Single file upload",
"operationId": "UploadFile",
"consumes": [
"multipart/form-data"
],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "file",
"in": "formData",
"description": "",
"required": false,
"type": "file"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "string"
}
}
}
}
}
}
} |
@eduherminio - that's OpenAPI (Swagger) 2.0, not OpenAPI 3.0. The 2.0 version does not support multi file uploads. |
Oops, totally right @webron, I'll close this and create a new one if I experience issues once I configure the project to use 3.0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Q&A
Swashbuckle.AspNetCore.SwaggerUI
v4.0.1Content & configuration
Example Swagger/OpenAPI definition:
Swagger-UI configuration options:
From
Swashbuckle.AspNetCore.SwaggerUI
Describe the bug you're encountering
Input type is
text
rather thanfile
when a method receives muliple files (eitherIEnumerable<IFormFile>
orIFormFileCollection
) as argument.Current behavior
Expected behavior
The text was updated successfully, but these errors were encountered: