private static void InitUIOption(SwaggerUIOptions c, SwaggerForOCelotUIOptions options) { c.ConfigObject = options.ConfigObject; c.DocumentTitle = options.DocumentTitle; c.HeadContent = options.HeadContent; c.IndexStream = options.IndexStream; c.OAuthConfigObject = options.OAuthConfigObject; c.RoutePrefix = options.RoutePrefix; }
private static void InitUIOption(SwaggerUIOptions c, SwaggerForOCelotUIOptions options, InnerSaceAPI api) { c.ConfigObject = options.ConfigObject; c.DocumentTitle = options.DocumentTitle; c.HeadContent = options.HeadContent; c.IndexStream = options.IndexStream; c.OAuthConfigObject = options.OAuthConfigObject; c.RoutePrefix = options.RoutePrefix; options.InjectJavascript("Swaggerinit.js"); //c.RoutePrefix = string.Empty; //c.SwaggerEndpoint("/swagger/v1/swagger.json", "Messages service getaway API V1"); c.OAuthClientId(api.ClientId); c.OAuthAppName(api.Name); }
/// <summary> /// Add Swagger generator for downstream services and UI into application pipeline. /// </summary> /// <param name="app">The application builder.</param> /// <param name="configuration">The configuration.</param> /// <param name="setupAction">Setup <see cref="SwaggerForOCelotUIOptions"/></param> /// <returns> /// <see cref="IApplicationBuilder"/>. /// </returns> public static IApplicationBuilder UseSwaggerForOcelotUI(this IApplicationBuilder app, IConfiguration configuration, Action <SwaggerForOCelotUIOptions> setupAction) { var options = new SwaggerForOCelotUIOptions(); setupAction?.Invoke(options); UseSwaggerForOcelot(app, options); app.UseSwaggerUI(c => { InitUIOption(c, options); var endPoints = GetConfugration(configuration); AddSwaggerEndPoints(c, endPoints, options.EndPointBasePath); }); return(app); }
/// <summary> /// Initializes a new instance of the <see cref="SwaggerForOcelotMiddleware"/> class. /// </summary> /// <param name="next">The next delegate.</param> /// <param name="options">The options.</param> /// <param name="reRoutes">The Ocelot ReRoutes configuration.</param> /// <param name="swaggerEndPoints">The swagger end points.</param> /// <param name="httpClientFactory">The HTTP client factory.</param> public SwaggerForOcelotMiddleware( RequestDelegate next, SwaggerForOCelotUIOptions options, IOptions <List <ReRouteOptions> > reRoutes, IOptions <List <SwaggerEndPointOptions> > swaggerEndPoints, IHttpClientFactory httpClientFactory, ISwaggerJsonTransformer transformer) { _transformer = Check.NotNull(transformer, nameof(transformer)); _next = Check.NotNull(next, nameof(next)); _reRoutes = Check.NotNull(reRoutes, nameof(reRoutes)); Check.NotNull(swaggerEndPoints, nameof(swaggerEndPoints)); _httpClientFactory = Check.NotNull(httpClientFactory, nameof(httpClientFactory)); _swaggerEndPoints = new Lazy <Dictionary <string, SwaggerEndPointOptions> >(() => swaggerEndPoints.Value.ToDictionary(p => $"/{p.KeyToPath}", p => p)); }
private static void UseSwaggerForOcelot(IApplicationBuilder app, SwaggerForOCelotUIOptions options) { app.Map(options.EndPointBasePath, builder => builder.UseMiddleware <OcelotSwaggerMiddleware>(options)); }