Skip to content

Failed to load API definition. #1

@xuyae573

Description

@xuyae573

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions