2

I have just install Swashbuckle.AspNetCore 5.6.3 and do all the configurations where needed.

when I run the debugger and got the localhost:65183/swagger/index.html from by browser it is showing the following error in console:

Uncaught TypeError: Cannot read property 'forEach' of undefined at window.onload (index.html:51) window.onload @ index.html:51 load (async) (anonymous) @ index.html:46

I have the following folder structure. Here is screenshot of my Project in Visual Studio.

Project Structure

1 Answer 1

4

I figured out the problem. I missed a line in the configuration.

This line

app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });
1
  • Just did basically the exact same thing and ran into the same issue. It's misleading because the documentation: learn.microsoft.com/en-us/aspnet/core/tutorials/… Just says to add a line like this: app.UseSwaggerUI(); But then has a note later that you should add something like what you have, but only mentions it if you want a different endpoint for the UI or want the Swagger 2.0 format. Microsoft should maybe adjust their documentation - I might file a bug about this.
    – olucafont6
    Commented Nov 29, 2021 at 23:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.