Hi,
I have a ASP.NET Core Web API action as follows:
````
[HttpPost("RemoveAccessRights")]
public async Task
{
// Get vbc workspace
var workspace = GetWorkspace();
foreach (var record in input)
{
await Task.Run(() => RemoveUserAccessRights(record, workspace));
}
return Ok();
}
The swagger json is:
"/api/Users/RemoveAccessRights": {
"post": {
"tags": [
"Users"
],
"operationId": "Users_RemoveAccessRights",
"parameters": [
{
"name": "input",
"in": "body",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/CreateOrUpdateUserAccessDto"
}
},
"x-nullable": true
}
],
"responses": {
"200": {
"description": "",
"schema": {
"type": "file"
},
"x-nullable": true
}
}
}
},
The client-side generation is:
public removeAccessRights(input: CreateOrUpdateUserAccessDto[]): Observable
````
How come IActionResult is transformed to FileResponse?
Thanks
Bilal
NSwag uses reflection to determine the response type - if the return type is IActionResult it does not know what the response type is and will fallback to file which is the most flexible type...
See https://github.com/RSuter/NSwag/wiki/WebApiToSwaggerGenerator#specify-the-response-type-of-an-action
So what will be the best workaround to return for example nothing?
Add
[SwaggerResponse(typeof(void))]
Or use the signature
public async Task RemoveAccessRights([FromBody]List<CreateOrUpdateUserAccessDto> input)
Thanks @RSuter :)
Thank you for logging this issue. It saved me a ton of time.
Most helpful comment
Add