title: Swagger .NETCORE can't read json
body: <p>I'm having a trouble with swagger in .netcore. I've tried everything and nothing. I saw another similar questions, but nothing works for me. Running my webapi app with swagger, always returns "Can't read swagger JSON from <a href="http://localhost:5000/api/swagger/v1/swagger.json" rel="noreferrer">http://localhost:5000/api/swagger/v1/swagger.json</a>".</p>
  
  <p>My codes:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      // Add framework services.
      services.AddApplicationInsightsTelemetry(Configuration);
      services.AddCors(options =&gt; options.AddPolicy("AllowAll", p =&gt; p.AllowAnyOrigin()
                                                                  .AllowAnyMethod()
                                                                  .AllowAnyHeader()));
      services.AddMvc();
      services.AddSwaggerGen();
  
      services.ConfigureSwaggerGen(options =&gt;
      {
          var info = new Info
          {
              Version = "v1",
              Title = "Web API Multiprodutos",
              Description = "Web API Multiprodutos",
              Contact = new Contact { Name = "Marcos Monte", Url = "www.arrowbus.com.br" }
          };
  
          options.SingleApiVersion(info);
  
          string caminhoAplicacao = AppContext.BaseDirectory;
          string nomeAplicacao =
              PlatformServices.Default.Application.ApplicationName;
          string caminhoXmlDoc =
              Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml");
  
          options.IncludeXmlComments(caminhoXmlDoc);
          options.IgnoreObsoleteProperties();
          options.IgnoreObsoleteActions();
          options.DescribeAllEnumsAsStrings();
      });
  
      services.AddTransient&lt;IServicoSimulacao, ServicoSimulacao&gt;();
  
      services.AddTransient&lt;IAplicacaoLocalidade, AplicacaoEndereco&gt;();
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      loggerFactory.AddConsole(Configuration.GetSection("Logging"));
      loggerFactory.AddDebug();
  
      app.UseApplicationInsightsRequestTelemetry();
      app.UseApplicationInsightsExceptionTelemetry();
  
      app.UseCors(builder =&gt;
      {
          builder.AllowAnyOrigin();
          builder.AllowAnyMethod();
          builder.AllowAnyHeader();
      });
  
      app.UseCors("AllowAll");
  
      app.UseMvc();
      app.UseMvcWithDefaultRoute();
  
      app.UseSwagger((httpRequest, swaggerDoc) =&gt;
      {
          swaggerDoc.Host = httpRequest.Host.Value;
      });
  
      app.UseSwaggerUi(swaggerUrl: Configuration["AppSettings:VirtualDirectory"] + "/swagger/v1/swagger.json", baseRoute: "swagger/ui");
  }
  </code></pre>
  
  <p>Project.json</p>
  
  <pre><code>{
    "dependencies": {
      "Microsoft.NETCore.App": {
        "version": "1.0.1",
        "type": "platform"
      },
      "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
      "Microsoft.AspNetCore.Mvc": "1.0.1",
      "Microsoft.AspNetCore.Routing": "1.0.1",
      "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
      "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
      "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
      "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
      "Microsoft.Extensions.Configuration.Json": "1.0.0",
      "Microsoft.Extensions.Logging": "1.0.0",
      "Microsoft.Extensions.Logging.Console": "1.0.0",
      "Microsoft.Extensions.Logging.Debug": "1.0.0",
      "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
      "Aplicacao.Multiprodutos": "1.0.0-*",
      "Dominio.MultiProdutos": "1.0.0-*",
      "Swashbuckle": "6.0.0-beta902",
      "Swashbuckle.AspNetCore": "1.0.0",
      "Swashbuckle.SwaggerGen": "6.0.0-beta902",
      "Swashbuckle.SwaggerUi": "6.0.0-beta902",
      "Infra.Repositorio.MultiProdutos": "1.0.0-*"
    },
  
    "tools": {
      "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
    },
  
    "frameworks": {
      "netcoreapp1.0": {
        "imports": [
          "dotnet5.6",
          "portable-net45+win8"
        ]
      }
    },
  
    "buildOptions": {
      "emitEntryPoint": true,
      "preserveCompilationContext": true,
      "xmlDoc": true
    },
  
    "runtimeOptions": {
      "configProperties": {
        "System.GC.Server": true
      }
    },
  
    "publishOptions": {
      "include": [
        "wwwroot",
        "**/*.cshtml",
        "appsettings.json",
        "web.config"
      ]
    },
  
    "scripts": {
      "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
    }
  }
  </code></pre>
  
  <p>Please, help me.Thanks in advance.</p>
  
  <p>UPDATE</p>
  
  <p>I'm using now VS 2017 and .NET Core 1.1, but the problem remains. New code below:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddMemoryCache();
  
      services.AddMvc();
  
      services.AddCors(options =&gt;
                          options.AddPolicy("AllowAll",
                          p =&gt; p.AllowAnyOrigin()
                              .AllowAnyMethod()
                              .AllowAnyHeader()));
  
  
  
      // Register the Swagger generator, defining one or more Swagger documents
      services.AddSwaggerGen(c =&gt;
      {
          c.SwaggerDoc("v1", new Info
          {
              Version = "v1",
              Title = "Web API Multiprodutos",
              Description = "Web API Multiprodutos",
              Contact = new Contact { Name = "Marcos Monte", Url = "www.arrowbus.com.br" }
          });
  
          string caminhoAplicacao = AppContext.BaseDirectory;
          string nomeAplicacao =
              PlatformServices.Default.Application.ApplicationName;
          string caminhoXmlDoc =
              Path.Combine(caminhoAplicacao, $"swagger.xml");
  
          c.IncludeXmlComments(caminhoXmlDoc);
          c.IgnoreObsoleteProperties();
          c.IgnoreObsoleteActions();
          c.DescribeAllEnumsAsStrings();
      });
  
      //Contextos
      services.AddDbContext&lt;ADFContexto&gt;();
      services.AddDbContext&lt;MPFIndicacaoContexto&gt;();
      services.AddDbContext&lt;MPFContexto&gt;();
  
      //Aplicaçãões
      services.AddScoped&lt;IAplicacaoAtendimento, AplicacaoAtendimento&gt;();
      services.AddScoped&lt;IAplicacaoLocalidade, AplicacaoEndereco&gt;();
      services.AddScoped&lt;IAplicacaoEndereco, AplicacaoEndereco&gt;();
      services.AddScoped&lt;IAplicacaoTelefone, AplicacaoTelefone&gt;();
      services.AddScoped&lt;IAplicacaoEsteira, AplicacaoEsteira&gt;();
      services.AddScoped&lt;IAplicacaoCliente, AplicacaoCliente&gt;();
      services.AddScoped&lt;IAplicacaoLoja, AplicacaoLoja&gt;();
  
      //Serviços
      services.AddScoped&lt;IServicoSimulacao, ServicoSimulacao&gt;();
      services.AddScoped&lt;IServicoAtendimento, ServicoAtendimento&gt;();
  
  
      //Repositorios
      services.AddScoped&lt;IRepositorioFichaFinanceira, RepositorioFichaFinanceira&gt;();
      services.AddScoped&lt;IRepositorioEmprestimo, RepositorioEmprestimo&gt;();
      services.AddScoped&lt;IRepositorioCliente, RepositorioCliente&gt;();
      services.AddScoped&lt;IRepositorioProdutosOportunidade, RepositorioProdutoOportunidade&gt;();
      services.AddScoped&lt;IRepositorioAtendimento, RepositorioAtendimento&gt;();
      services.AddScoped&lt;IRepositorioIndicacao, RepositorioIndicacao&gt;();
      services.AddScoped&lt;IRepositorioEndereco, RepositorioEndereco&gt;();
      services.AddScoped&lt;IRepositorioTelefone, RepositorioTelefone&gt;();
      services.AddScoped&lt;IRepositorioHistoricoAtendimento, RepositorioHistoricoAtendimento&gt;();
      services.AddScoped&lt;IRepositorioEsteira, RepositorioEsteira&gt;();
      services.AddScoped&lt;IRepositorioLoja, RepositorioLoja&gt;();
      services.AddScoped&lt;IRepositorioCampanha, RepositorioCampanha&gt;();
      services.AddScoped&lt;IRepositorioStatus, RepositorioStatus&gt;();
      services.AddScoped&lt;IRepositorioSimulacao, RepositorioSimulacao&gt;();
      services.AddScoped&lt;IRepositorioUsuario, RepositorioUsuario&gt;();
      services.AddScoped&lt;IAutenticacaUsuario, AutenticacaoUsuarioHydra&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("Logging"));
      loggerFactory.AddDebug();
  
      app.UseStaticFiles();
  
      ConfigureAuth(app);
  
      app.UseCors(builder =&gt;
      {
          builder.AllowAnyHeader();
          builder.AllowAnyMethod();
          builder.AllowAnyOrigin();
      });
  
      app.UseCors("AllowAll");
  
  
      app.UseMvc();
      app.UseMvcWithDefaultRoute();
  
      app.UseSwagger(c =&gt; { c.RouteTemplate = "{apiVersion}/swagger.json"; });
  
      //specifying the Swagger JSON endpoint.
      app.UseSwaggerUI(c =&gt;
      {
           c.SwaggerEndpoint("v1/swagger.json", "Some API");
      });
  }
  </code></pre>