Swagger UI Hangs on `Fetching resource list: Please wait`
Asked Answered
R

4

12

I am trying to install Swagger API in my ASP.NET WEB API 2 project.

I have installed the swashbuckle ( v5.4.0 ) nuget package. I then debug the project and got to URL/swagger/ui/index where I get Fetching resource list: http://localhost:44432/swagger/docsv1; Please wait. After some time I get the chrome page not responding. Kill or Wait screen.

I am using default SwaggerConfig.cs.

I have run the json validation test at: https://online.swagger.io/validator/debug?url={SwaggerJSON URL HERE}/docs/v1

What steps can I take to further debug my issue here?

[Edit] I accidentally left my one tab open, and after a good 30 minutes the page rendered. What could be causing this? Possibly a endless recursion when parsing the json file?

Realpolitik answered 30/8, 2016 at 6:29 Comment(1)
Did you ever find a solution to this? I'm facing same issue, but with v.5.6.0 insted.Antiphonal
M
2

https://github.com/domaindrivendev/Swashbuckle/issues/891 Im not sure if this will help you but you can check out this issue.

It would be interesting to see if its the same issue affecting you on your local machine where it was only happening to me when I hosted it on the internet.

I just forked the project and changed the buffer size and used the custom DLL while I'm waiting for a response on the issue.

Mogilev answered 12/10, 2016 at 7:15 Comment(1)
I just downgraded the nuget package to an older version.Realpolitik
M
0

I had this same problem. This is how I solved it.

I accidentally left my one tab open, and after a good 30 minutes the page rendered. What could be causing this? Possibly a endless recursion when parsing the json file?

Check the extension/size of your json response. Probably there's a lot of objects and arrays inside of it.

I was able to fix this problem by using a DTO object to make a copy of the EF object (I´d used AutoMapper for this, or alike). That way, you´d be cherry picking what your need, and not just getting additional references that you won't need (virtual classes with references to other classes in an EF class, may do this) and would be really too time consuming to process/get.

This way, you'd be exposing in your Web API Swagger, a DTO object, which is a simplified version of your EF/DB entity.

Here´s a quick...

Example:

Action Method

// GET: api/MyWebApiApp/GetItemById/7
public TheItemDTO GetItemById(int id)
{
    TheItem item = _repositoryLayer.GetItemById(id); // from EF, and from DB
    if (item == null) return null;
    else return new TheItemDTO(TheItem); // return the DTO, from your DB item
}

DTO Class

  • Used locally at your Web API scope. It favors loose coupling.
public class TheItemDTO
{

    public TheItemDTO(TheItem item)
    {
        id = item.id;
        value = item.value;
    }

    public int id { get; set; }
    public string value { get; set; }
}
Multiplier answered 16/12, 2022 at 20:2 Comment(1)
Also, here´s a good conversation on this issue: github.com/domaindrivendev/Swashbuckle.WebApi/issues/…Multiplier
B
0

I had the same error, however none of the answers above helped me

In my case in each Action I had the following code snippet

[ResponseType(typeof(<your-response-type>))]

After removing this snippet from the methods Swagger rendered completely

Bawl answered 18/7, 2023 at 18:55 Comment(0)
P
0

I'm updating this as I encountered the issue today.

The end issue was having the definition of a type: array alone without defining its items:

products:
    type: array

Makes it crash.

products:
    type: array
    items:
      type: string

Work fine.

My first solution was to change the UI VERSION to version 3 in app config : app.config["SWAGGER"] = { "title": "Swagger xxxxxx", "uiversion": 3, }

It doesn't solve the end issue but make the UI load.

I'm using the docstrings of my route in YAML format to generate the JSON.

Patronize answered 30/10, 2023 at 15:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.