macOS - no Swagger on Tutorial: Create a web API
Since this is a "Hello World" kind of situation, more help when things go wrong would be appreciated. I followed the instructions and the /Swagger URL wouldn't load. I'm sure I'm missing some prerequisite, but don't know what yet.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 583ae3e7-5915-f22b-e54c-6c100cf2a7da
- Version Independent ID: 95f2549e-29f9-e31a-b4d0-432b971643ff
- Content: Tutorial: Create a web API with ASP.NET Core
- Content Source: aspnetcore/tutorials/first-web-api.md
- Product: aspnet-core
- Technology: aspnetcore-tutorials
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
Most likely you don't have .NET 5 installed or unchecked Enable OpenAPI support

I have .NET 5 installed and was having the same problem. I fixed it by going to Project Properties -> Debug and setting Hosting Model to "Out of Process".
I have .NET 5 installed and was having the same problem. I fixed it by going to Project Properties -> Debug and setting Hosting Model to "Out of Process".
That has nothing to do with Swagger endpoints.
Perhaps you unchecked Enable OpenAPI support

Most likely you don't have .NET 5 installed or unchecked Enable OpenAPI support
this solution worked for me
I'm trying this tutorial on my MacBook, and I see the WeatherForecast page, but the swagger page is not loading. The page never loads, it is just blank. I have .NET 5 installed and I checked Enable OpenAPI support
I'm trying this tutorial on my MacBook, and I see the WeatherForecast page, but the swagger page is not loading. The page never loads, it is just blank. I have .NET 5 installed and I checked Enable OpenAPI support
I'm in the same situation as @drock702
I'm trying this tutorial on my MacBook, and I see the WeatherForecast page, but the swagger page is not loading. The page never loads, it is just blank. I have .NET 5 installed and I checked Enable OpenAPI support
I'm in the same situation as @drock702
@paulzolnierczyk - I got it to work by installing Swagger/Swashbuckle package and "Rebuild All" my project. https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-5.0&tabs=visual-studio-mac
@wadepickett can you test this on macOS?
Hello. Im currently using Visual Studio on Mac, and in tutorial page the swagger initial configuration for it to work is missing. So in "Test your project" section, the swagger configuration is missing, leaving
services.AddControllers();
//Swagger configuration
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "TodoApi", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TodoApi v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}`
. . .
This bit of code necessary to configure swagger is shown in the same page in the section "Register the database context" (the lines commented).
I hope it helps.
I am still not able to run the test api provided in the "https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio-code". localhost:5001(/swagger) shows just "This page isn’t workinglocalhost didn’t send any data. ERR_EMPTY_RESPONSE"
Please help asap. @Rick-Anderson
Note: Using VS Code
Hello. Im currently using Visual Studio on Mac, and in tutorial page the swagger initial configuration for it to work is missing. So in "Test your project" section, the swagger configuration is missing, leaving /Startup.cs as follows: . . . ` // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) {
services.AddControllers(); //Swagger configuration services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "TodoApi", Version = "v1" }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TodoApi v1")); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }`. . .
This bit of code necessary to configure swagger is shown in the same page in the section "Register the database context" (the lines commented).
I hope it helps.
I try to paste the swagger config code to the startup.cs file , but getting error :(
I tried a new project to see what was happening. First go to your project root folder and run:
dotnet add package Swashbuckle.AspNetCore -v 5.6.3
This will add the Swashbuckle package into your project containing Swagger. Than you can change your Startup.cs following:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
namespace <your_namespace_here>
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "GpioService", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "GpioService v1"));
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
Just change your namespace to your project namespace.
For me it's working like a charm:

I hope it helps.
Make sure you have the .NET 5.0 SDK installed and that .NET 5.0 is selected as the target framework in the project properties. For those who are experiencing this problem on Windows, make sure you're using Chrome rather than IE to load the Swagger page. In IE it just shows a blank page, but in Chrome it works.
make sure you're using Chrome rather than IE to load the Swagger page. In IE it just shows a blank page, but in Chrome it works.
Edge works too. Thanks for the tip.
That's nice, thanks I will try all of your suggestions.
Thanks
Paramita Roy
Senior Quality Assurance Analyst II (IT Analysis)
Mobile: +1 682-300-6222
https://www.linkedin.com/in/paramita-roy-297197104/
On Wed, Sep 15, 2021 at 3:04 PM Rick Anderson @.***> wrote:
make sure you're using Chrome rather than IE to load the Swagger page. In IE it just shows a blank page, but in Chrome it works.
Edge works too. Thanks for the tip.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dotnet/AspNetCore.Docs/issues/21647#issuecomment-920300287, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP56D5AEPSJ2LK3VHVEYRE3UCDU4BANCNFSM4YMU5C3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
This video is the solution: https://www.youtube.com/watch?v=UG1AdlmrJGQ&t=289s Create ASP.Net Core Web API project using CLI and VS Code | ASP.Net Core Web API Tutorial
I tried a new project to see what was happening. First go to your project root folder and run:
dotnet add package Swashbuckle.AspNetCore -v 5.6.3This will add the Swashbuckle package into your project containing Swagger. Than you can change your Startup.cs following:
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; namespace <your_namespace_here> { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "GpioService", Version = "v1" }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "GpioService v1")); } app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } }Just change your namespace to your project namespace. For me it's working like a charm:
I hope it helps.
This fixed the problem for me. (Using VS for mac). Note that there are several Swashbuckle packages you can install, and the one referenced in this reply contains all the needed child packages.
Awesome, thanks!
On Tue, Oct 26, 2021 at 2:03 PM Shad @.***> wrote:
I tried a new project to see what was happening. First go to your project root folder and run:
dotnet add package Swashbuckle.AspNetCore -v 5.6.3
This will add the Swashbuckle package into your project containing Swagger. Than you can change your Startup.cs following:
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models;
namespace <your_namespace_here> { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "GpioService", Version = "v1" }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "GpioService v1")); } app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } }}
Just change your namespace to your project namespace. For me it's working like a charm: [image: Screen Shot 2021-09-01 at 18 51 57] https://user-images.githubusercontent.com/12357601/131756038-47edcef4-d9d0-4e71-8d44-58e8cfabf7cb.png
I hope it helps.
This fixed the problem for me. VS Mac on 2020 MBP.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dotnet/AspNetCore.Docs/issues/21647#issuecomment-952181108, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP56D5DTX4KECKVPK2C2GKLUI3UNRANCNFSM4YMU5C3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- Paramita Roy Software Quality Assurance Analyst Contact No: 682-300-6222
Seems like a bug in macOS Visual Studio. While creating a web API project, the Enable Open API support checkbox works otherwise.
Uncheck it to add /swagger endpoint to your project. This is weird but worked.
@rohitsiddha why are you using .NET 5 and not .NET 6?