using Microsoft.OpenApi.Models; using Ocelot.DependencyInjection; using Ocelot.Middleware; namespace Gateway; public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddEndpointsApiExplorer(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "# gateway api..." }); }); services.AddOcelot(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseSwagger(); app.UseSwaggerUI(c => { var services = Configuration.GetSection("Services").Get>(); foreach (var s in services) { c.SwaggerEndpoint($"/{s.ToLower()}/swagger/v1/swagger.json", s); } }); app.UseOcelot().Wait(); } }