question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible bug: Incorrect mapping IActionResult -> FileResponse

See original GitHub issue

Hi, I have a ASP.NET Core Web API action as follows:

        [HttpPost("RemoveAccessRights")]
        public async Task<IActionResult> RemoveAccessRights([FromBody]List<CreateOrUpdateUserAccessDto> input)
        {
            // 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<FileResponse> {}

How come IActionResult is transformed to FileResponse?

Thanks Bilal

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
RicoSutercommented, Nov 2, 2017

Add

[SwaggerResponse(typeof(void))]
1reaction
melucascommented, Apr 21, 2019

Thank you for logging this issue. It saved me a ton of time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect mapping IActionResult -> FileResponse · Issue # ...
Possible bug : Incorrect mapping IActionResult -> FileResponse #1030 ... return type is IActionResult it does not know what the response type ...
Read more >
Returning a file to View/Download in ASP.NET MVC
I'm encountering a problem sending files stored in a database back to the user in ASP.NET MVC. What I want is a view...
Read more >
Format response data in ASP.NET Core Web API
Learn how to format response data in ASP.NET Core Web API.
Read more >
Lee's Blog - RSSing.com
On a good googlefu day I stumbled on the solution of telling Swashbuckle to map all instances of FileContentResult with "file" in startup.cs ......
Read more >
[Fix]-Can form submit file(s) to ASP.NET Core controller action ...
Coding example for the question Can form submit file(s) to ASP.NET Core controller action without knowing field name in advance?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found