/// <summary>Addes 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 UseSwaggerUi( this IApplicationBuilder app, Assembly webApiAssembly, SwaggerUiOwinSettings settings) { return(app.UseSwaggerUi(new[] { webApiAssembly }, settings)); }
/// <summary>Addes 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 generator settings.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, IEnumerable<Assembly> webApiAssemblies, SwaggerUiOwinSettings settings) { var controllerTypes = webApiAssemblies.SelectMany(WebApiToSwaggerGenerator.GetControllerClasses); return app.UseSwaggerUi(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 UseSwaggerUi( this IApplicationBuilder app, IEnumerable <Type> controllerTypes, Action <SwaggerUiOwinSettings> configure = null) { var settings = new SwaggerUiOwinSettings(); configure?.Invoke(settings); return(app.UseSwaggerUi(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings))); }
/// <summary>Addes 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="settings">The Swagger generator settings.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, IEnumerable <Type> controllerTypes, SwaggerUiOwinSettings settings) { app.UseMiddleware <RedirectMiddleware>(settings.SwaggerUiRoute, settings.SwaggerUiRoute + "/index.html?url=" + Uri.EscapeDataString(settings.SwaggerRoute)); app.UseMiddleware <SwaggerMiddleware>(settings.SwaggerRoute, controllerTypes, settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.SwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.SwaggerUi") }); return(app); }
/// <summary>Addes 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="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, IEnumerable<Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.UseMiddleware<RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerUiRoute); app.UseMiddleware<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.UseMiddleware<SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.SwaggerUi") }); return app; }
public SwaggerUiIndexMiddleware(RequestDelegate nextDelegate, string indexPath, SwaggerUiOwinSettings settings) { _nextDelegate = nextDelegate; _indexPath = indexPath; _settings = settings; }
/// <summary>Addes 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 UseSwaggerUi( this IApplicationBuilder app, SwaggerUiOwinSettings settings) { return(app.UseSwaggerUi(null, settings, null)); }
/// <summary>Addes 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 UseSwaggerUi( this IApplicationBuilder app, IEnumerable<Assembly> webApiAssemblies, SwaggerUiOwinSettings settings) { var controllerTypes = webApiAssemblies.SelectMany(WebApiToSwaggerGenerator.GetControllerClasses); return app.UseSwaggerUi(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings)); }
/// <summary>Addes 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 UseSwaggerUi( this IApplicationBuilder app, Assembly webApiAssembly, SwaggerUiOwinSettings settings) { return app.UseSwaggerUi(new[] { webApiAssembly }, settings); }
/// <summary>Addes 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="settings">The Swagger UI and generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, IEnumerable<Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { if (controllerTypes != null) app.UseMiddleware<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.UseMiddleware<RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.UseMiddleware<SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.SwaggerUi") }); return app; }
/// <summary>Addes 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 UseSwaggerUi( this IApplicationBuilder app, SwaggerUiOwinSettings settings) { return app.UseSwaggerUi(null, settings, null); }