grissomlau/jimu.demo

Failed to load API definition.

Opened this issue · 0 comments

Failed to load API definition.

Fetch error Internal Server Error /swagger/v1/swagger.json

API Gateway Configuration:

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.UseJimuSwagger(); // 添加 Swagger 支持 
            services.UseJimu();

            //  services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseJimuSwagger(); // 添加 Swagger 支持

            var host = new ServiceHostClientBuilder(new Autofac.ContainerBuilder())
               .UseLog4netLogger()
               .UsePollingAddressSelector()
               .UseDotNettyForTransfer()
               .UseInServerForDiscovery(new Jimu.DotNettyAddress("127.0.0.1", 8001))
               .Build();
            app.UseJimu(host);
        
            host.Run();
        }
    }

Server:

var hostBuilder = new ServiceHostServerBuilder(new Autofac.ContainerBuilder())
             .UseLog4netLogger()
             .LoadServices("QuickStart.Services")
             .UseDotNettyForTransfer("127.0.0.1", 8001)
             .UseInServerForDiscovery()
             ;
          using (var host = hostBuilder.Build())
          {
              host.Run();
              Console.ReadLine();
          }


Service Setting:

[JimuServiceRoute("/api/v1/users")]
  public interface IUserService : IJimuService
  {
      [JimuService(CreatedBy = "grissom", CreatedDate = "2018-07-17")]
      string GetName(string id);
  }

  public class UserService : IUserService
  {
      public string GetName(string id)
      {
          return $"user id {id}, name enjoy!";
      }
  }

How to resolve?