Obtener error:
Publicar ha encontrado un error. Asegúrese de que Startup.cs para su aplicación llame a AddSwaggerGen desde ConfigureServices para generar un archivo swagger.
Pero startup.cs aquí está completamente cargado:
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "WeatherForecast API", 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("v1/swagger.json", "WeatherForecast API V1"); }); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }Su código es correcto. Hay el mismo problema en GitHub y parece que el problema es la ruta de su proyecto.
Mira este comentario. https://github.com/dotnet/AspNetCore.Docs/issues/20330#issuecomment-722461550