NSwag: FileResponse compile-time error
Hi,
I’I have one issue with NSWAG (i’m using the latest 12.0.10.0).
When i have in openapi 3.0 definition , response for api which downloads a file, like this:
responses: ‘200’: description: The content of the file content: application/octet-stream: schema: type: string format: binary
In my C# Web Api controller generated code , i have compile-time error in:
HttpResponseMessage response = Request.CreateResponse(status, result.Result);
where Result doesn’t exists in FileResponse class:
public partial class FileResponse : System.IDisposable
{
private System.IDisposable _client;
private System.IDisposable _response;
public int StatusCode { get; private set; }
public System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; }
public System.IO.Stream Stream { get; private set; }
public bool IsPartial
{
get { return StatusCode == 206; }
}
public FileResponse(int statusCode, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response)
{
StatusCode = statusCode;
Headers = headers;
Stream = stream;
_client = client;
_response = response;
}
public void Dispose()
{
if (Stream != null)
Stream.Dispose();
if (_response != null)
_response.Dispose();
if (_client != null)
_client.Dispose();
}
}
So either this is a compile-time error with generated code or i should use some other type of response ?
Thank you.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 20 (9 by maintainers)
Commits related to this issue
- Return FileResult type for binary response if an AspNetCore controller is generated — committed to Alamaster99/NSwag by deleted user 5 years ago
@novakmarkov, @RicoSuter, @Alamaster99,
Is there any update on this?
I temporaly solved it by adding the following in the generated c# client
So the output is
I think for controllers it should not generate FileResponse at all but just return a Stream - or is this not working in ASP.NET (Core)?