diff --git a/README.md b/README.md index 6495f71..6d205f1 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,16 @@ app.UseSwaggerForOcelotUI(opt => { }) ``` +You can optionally customize SwaggerUI: +```CSharp +app.UseSwaggerForOcelotUI(opt => { + // swaggerForOcelot options +}, uiOpt => { + //swaggerUI options + uiOpt.DocumentTitle = "Gateway documentation"; +}) + ``` + 6. Show your microservices interactive documentation. > `http://ocelotserviceurl/swagger` diff --git a/src/MMLib.SwaggerForOcelot/Configuration/SwaggerForOcelotUIOptions.cs b/src/MMLib.SwaggerForOcelot/Configuration/SwaggerForOcelotUIOptions.cs index 2749da8..6d50c8e 100644 --- a/src/MMLib.SwaggerForOcelot/Configuration/SwaggerForOcelotUIOptions.cs +++ b/src/MMLib.SwaggerForOcelot/Configuration/SwaggerForOcelotUIOptions.cs @@ -10,7 +10,7 @@ namespace MMLib.SwaggerForOcelot.Configuration /// Configuration for Swagger UI. /// /// - public class SwaggerForOcelotUIOptions : SwaggerUIOptions + public class SwaggerForOcelotUIOptions { /// /// The relative path to gateway swagger generator. diff --git a/src/MMLib.SwaggerForOcelot/Middleware/BuilderExtensions.cs b/src/MMLib.SwaggerForOcelot/Middleware/BuilderExtensions.cs index 55b9da2..b41f972 100644 --- a/src/MMLib.SwaggerForOcelot/Middleware/BuilderExtensions.cs +++ b/src/MMLib.SwaggerForOcelot/Middleware/BuilderExtensions.cs @@ -20,12 +20,14 @@ public static class BuilderExtensions /// /// The application builder. /// Setup + /// Setup SwaggerUI /// /// . /// public static IApplicationBuilder UseSwaggerForOcelotUI( this IApplicationBuilder app, - Action setupAction = null) + Action setupAction = null, + Action setupUiAction = null) { SwaggerForOcelotUIOptions options = app.ApplicationServices.GetService>().Value; setupAction?.Invoke(options); @@ -33,7 +35,7 @@ public static class BuilderExtensions app.UseSwaggerUI(c => { - InitUIOption(c, options); + setupUiAction?.Invoke(c); IReadOnlyList endPoints = app .ApplicationServices.GetService().GetAll(); @@ -95,15 +97,5 @@ static string GetDescription(SwaggerEndPointConfig config) } } } - - 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; - } } }