Installed package:
"Swashbuckle.AspNetCore" Version="5.0.0"
When serializing a controller method with IFormFile with the following statement:
dotnet swagger tofile --serializeasv2 --output bin/swagger.json $(OutputPath)$(AssemblyName).dll v1
the generated output in the swagger.json is the following(excerpt)
{
"in": "formData",
"name": "FormFile",
"required": true,
"type": "string",
"format": "binary"
}
The OpenApi documentation states the followingen:
https://swagger.io/docs/specification/data-models/data-types/#file
I would expect the type to be of "file".
Is this a bug wih the parameter --serializeasv2? Or are we doing something wrong? Sadly the generated output does not work correctly with AutoRest since it doesn't support OpenApiV3.
Thank you!
I am also affected by this issue. Any idea how to work around this?
Worked around this by adding
c.MapType(typeof(IFormFile), () => new OpenApiSchema() { Type = "file", Format = "binary" });
to AddSwaggerGen.
@RisaI Thanks for your solution, I think you can further remove 'Format = "binary"' because OpenApiV2 doesn't know about it.
Most helpful comment
Worked around this by adding
c.MapType(typeof(IFormFile), () => new OpenApiSchema() { Type = "file", Format = "binary" });to
AddSwaggerGen.