/// <summary>Adds the Swagger generator and Swagger UI to the pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="configure">Configure the Swagger settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerReDoc( this IApplicationBuilder app, IEnumerable <Type> controllerTypes, Action <SwaggerReDocSettings <WebApiToSwaggerGeneratorSettings> > configure = null, SwaggerJsonSchemaGenerator schemaGenerator = null) { var settings = new SwaggerReDocSettings <WebApiToSwaggerGeneratorSettings>(); configure?.Invoke(settings); if (controllerTypes != null) { app.UseMiddleware <WebApiToSwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings)); } app.UseMiddleware <RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.UseMiddleware <SwaggerUiIndexMiddleware <WebApiToSwaggerGeneratorSettings> >(settings.ActualSwaggerUiRoute + "/index.html", settings, "NSwag.AspNetCore.ReDoc.index.html"); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.ReDoc") }); return(app); }
/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="webApiAssembly">The Web API assembly to search for controller types.</param> /// <param name="settings">The Swagger UI and generator settings.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerReDoc( this IApplicationBuilder app, Assembly webApiAssembly, SwaggerReDocSettings settings) { return(app.UseSwaggerReDoc(new[] { webApiAssembly }, settings)); }
/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="webApiAssemblies">The Web API assemblies to search for controller types.</param> /// <param name="settings">The Swagger UI and generator settings.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerReDoc( this IApplicationBuilder app, IEnumerable <Assembly> webApiAssemblies, SwaggerReDocSettings settings) { var controllerTypes = webApiAssemblies.SelectMany(WebApiToSwaggerGenerator.GetControllerClasses); return(app.UseSwaggerReDoc(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings))); }
/// <summary>Adds the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="configure">Configure the Swagger generator and UI settings.</param> public static IApplicationBuilder UseSwaggerReDoc( this IApplicationBuilder app, IEnumerable <Type> controllerTypes, Action <SwaggerReDocSettings> configure = null) { var settings = new SwaggerReDocSettings(); configure?.Invoke(settings); return(app.UseSwaggerReDoc(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings))); }
/// <summary>Adds the Swagger UI (only) to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="settings">The Swagger UI settings.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerReDoc( this IApplicationBuilder app, SwaggerReDocSettings settings) { return(app.UseSwaggerReDoc(null, settings, null)); }