ASP.NET Core - Swashbuckle not creating swagger.json file

I had the same problem. Check http://localhost:XXXX/swagger/v1/swagger.json. If you get any a errors, fix them.

For example, I had an ambiguous route in a base controller class and I got the error: "Ambiguous HTTP method for action. Actions require an explicit HttpMethod binding for Swagger 2.0.". If you use base controllers make sure your public methods use the HttpGet/HttpPost/HttpPut/HttpDelete OR Route attributes to avoid ambiguous routes.

Then, also, I had defined both HttpGet("route") AND Route("route") attributes in the same method, which was the last issue for swagger.


If your application is hosted on IIS/IIS Express try the following:

c.SwaggerEndpoint("../swagger/v1/swagger.json", "MyAPI V1");

I believe you missed these two lines on your Configure:

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();

    // Enable middleware to serve generated Swagger as a JSON endpoint.
    app.UseSwagger();
    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("v1/swagger.json", "MyAPI V1");
    });
}

To access Swagger UI, the URL should be: http://localhost:XXXX/swagger/

The json can be found at the top of Swagger UI:

enter image description here