title: Swagger 500 error in web api
body: <p>When I access the swagger url: <code>http//localhost:50505/swagger/index</code>. I got the 500 error.</p>
  <p>Please help me to figure out.</p>
  <pre><code>namespace BandwidthRestriction.Controllers
  {
  [Route(&quot;api/[controller]&quot;)]
  public class BandwidthController : Controller
  {
      private SettingDbContext _context;
      private readonly ISettingRespository _settingRespository;
  
      public BandwidthController(ISettingRespository settingRespository)
      {
          _settingRespository = settingRespository;
      }
      public BandwidthController(SettingDbContext context)
      {
          _context = context;
      }
  
      // GET: api/Bandwidth
      [HttpGet]
      public IEnumerable&lt;Setting&gt; GetSettings()
      {
          return _settingRespository.GetAllSettings();
      }
  
      // GET: api/Bandwidth/GetTotalBandwidth/163
      [HttpGet(&quot;{facilityId}&quot;, Name = &quot;GetTotalBandwidth&quot;)]
      public IActionResult GetTotalBandwidth([FromRoute] int facilityId)
      {
          // ...
          return Ok(setting.TotalBandwidth);
      }
  
      // GET: api/Bandwidth/GetAvailableBandwidth/163
      [HttpGet(&quot;{facilityId}&quot;, Name = &quot;GetAvailableBandwidth&quot;)]
      public IActionResult GetAvailableBandwidth([FromRoute] int facilityId)
      {
          // ...
          var availableBandwidth = setting.TotalBandwidth - setting.BandwidthUsage;
          return Ok(availableBandwidth);
      }
  
      // PUT: api/Bandwidth/UpdateBandwidthChangeHangup/163/10
      [HttpPut]
      public void UpdateBandwidthChangeHangup([FromRoute] int facilityId, [FromRoute]int bandwidth)
      {
          _settingRespository.UpdateBandwidthHangup(facilityId, bandwidth);
      }
  
      // PUT: api/Bandwidth/UpdateBandwidthChangeOffhook/163/10
      [HttpPut]
      public void UpdateBandwidthChangeOffhook([FromRoute] int facilityId, [FromRoute] int bandwidth)
      {
          _settingRespository.UpdateBandwidthOffhook(facilityId, bandwidth);
      }
  
      // POST: api/Bandwidth/PostSetting/163/20
      [HttpPost]
      public bool PostSetting([FromRoute] int facilityId, [FromRoute]int bandwidth)
      {
          //
          return false;
      }
  }
  </code></pre>
  <p>The corresponding configuration code in <code>Startup.cs</code> is</p>
  <pre><code>public void ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services.AddEntityFramework()
              .AddSqlServer()
              .AddDbContext&lt;SettingDbContext&gt;(options =&gt;
                  options.UseSqlServer(Configuration[&quot;Data:DefaultConnection:ConnectionString&quot;]));
  
          services.AddMvc();
          services.AddSwaggerGen();
          services.ConfigureSwaggerDocument(options =&gt;
          {
              options.SingleApiVersion(new Info
              {
                  Version = &quot;v1&quot;,
                  Title = &quot;Bandwidth Restriction&quot;,
                  Description = &quot;Api for Bandwidth Restriction&quot;,
                  TermsOfService = &quot;None&quot;
              });
              // options.OperationFilter(new Swashbuckle.SwaggerGen.XmlComments.ApplyXmlActionComments(pathToDoc));
          });
  
          services.ConfigureSwaggerSchema(options =&gt;
          {
              options.DescribeAllEnumsAsStrings = true;
              //options.ModelFilter(new Swashbuckle.SwaggerGen.XmlComments.ApplyXmlTypeComments(pathToDoc));
          });
          // Add application services.
          services.AddTransient&lt;ISettingRespository, SettingRespository&gt;();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
      {
          loggerFactory.AddConsole(Configuration.GetSection(&quot;Logging&quot;));
          loggerFactory.AddDebug();
  
          app.UseIISPlatformHandler(options =&gt; options.AuthenticationDescriptions.Clear());
          app.UseStaticFiles();
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: &quot;default&quot;,
                  template: &quot;{controller}/{action}/{facilityId?}&quot;);
              routes.MapRoute(
                  name: &quot;&quot;,
                  template: &quot;{controller}/{action}/{facilityId}/{bandwidth}&quot;);
          });
  
          app.UseSwaggerGen();
          app.UseSwaggerUi();
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/kTRal.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kTRal.png" alt="1" /></a></p>
  <p>In firefox: the error is <code>unable to load swagger ui</code></p>