Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load API definition. #1

Open
xuyae573 opened this issue Jan 20, 2019 · 0 comments
Open

Failed to load API definition. #1

xuyae573 opened this issue Jan 20, 2019 · 0 comments

Comments

@xuyae573
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant