I am using Nswag to generate client library to consume an API created from .NET Core Application.
Currently I am using actions that returns IActionResult
to benefit from methods such as return NotFound();
and return Ok(objectValue);
If the return type is IActionresult
generated Csharp Client methods from Nswag have return type of FileResponse
.
If I change return type to a certain class then the same return type is returned from the generated methods. This will prevent to use the benefits that I mentioned before.
Usually the return type is from a known return type and never return an anonymous type.
I have managed to get the response from reading the Stream
from FileResponse
and converted it to an object with a generic method JsonConvert.DeserializeObject<T>(value);
but this seems to be extra work needed to be done.
Is there anything I am missing to handle FileResponse
return type? Is it better to change from IActionResult
to a known object?