title: Unable to resolve service for type 'Swashbuckle.AspNetCore.Swagger.ISwaggerProvider'
body: <p>I am starting a new <code>Core</code> Web API, and would like to add <code>Swagger</code> to my application.</p>
  
  <p>My current environment:</p>
  
  <ul>
  <li>.Net Core 3.0</li>
  <li>Swashbuckle.AspNetCore 5.0.0-rc4</li>
  </ul>
  
  <p>Here is my <code>Startup.cs</code> class and configuration:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
      {
          services.AddControllers();
  
          //AK: Enable CORS
          //CORS should be configured on host server.
          services.AddCors(setupAction =&gt;
          {
              setupAction.AddPolicy(DevCorsPolicyName,
                  builder =&gt;
                  {
                      builder.WithOrigins("*").AllowAnyHeader().AllowAnyMethod();
                  });
          });
  
          #region Configuration
  
          //Configuration File
          services.Configure&lt;AppSettingConfiguration&gt;(Configuration.GetSection("AppSettings"));
          //AutoMapper
          services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
  
          //Configure Swagger
          services.ConfigureSwaggerGen(c =&gt;
          {
              c.SwaggerDoc("v3", new OpenApiInfo
              {
                  Title = "GTrackAPI",
                  Version = "v3"
              });
          });
  
          #endregion
  
          #region Dependency Injection
  
          //Database context and repository
          services.AddDbContext&lt;IGTrackContext, GTrackContext&gt;(builder =&gt;
          {
              builder.UseSqlServer(connectionString: Configuration.GetConnectionString("gtrackConnection"), sqlServerOptionsAction: null);
          });
          services.AddScoped&lt;IGTrackRepository, GTrackRepository&gt;();
  
          //facade layers
          services.AddScoped&lt;IPersonFacade, PersonFacade&gt;();
  
          //Service layers
          services.AddScoped&lt;IPersonService, PersonService&gt;();
  
          #endregion
      }
  
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          //Enable development environment only settings
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
  
          //AK: Only allow all origins for development environmnet
          app.UseCors(DevCorsPolicyName);
  
          // Enable middleware to serve generated Swagger as a JSON endpoint.
          app.UseSwagger();
  
          // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
          // specifying the Swagger JSON endpoint.
          app.UseSwaggerUI(c =&gt;
          {
              c.SwaggerEndpoint("/swagger/v1/swagger.json", "GTrackAPI");
              c.RoutePrefix = string.Empty; //Configures swagger to load at application root
          });
  
          app.UseRouting();
  
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
          });
      }
  </code></pre>
  
  <p>When I run my application, I get the following error:</p>
  
  <blockquote>
    <p>InvalidOperationException: Unable to resolve service for type 'Swashbuckle.AspNetCore.Swagger.ISwaggerProvider' while attempting to Invoke middleware 'Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware'.</p>
  </blockquote>
  
  <p>Here is the <code>Stacktrace</code>:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: Unable to resolve service for type 'Swashbuckle.AspNetCore.Swagger.ISwaggerProvider' while attempting to Invoke middleware 'Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware'.
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.GetService(IServiceProvider sp, Type type, Type middleware)
       at lambda_method(Closure , Object , HttpContext , IServiceProvider )
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;>c__DisplayClass4_1.b__2(HttpContext context)
       at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context, ICorsPolicyProvider corsPolicyProvider)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;>c__DisplayClass4_1.b__2(HttpContext context)
       at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)</p>
  </blockquote>
  
  <p>It is pretty clear that I am missing something here, not sure exactly what.  Any help would be appreciated.</p>