// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); var swaggerSettings = new SwaggerUiOwinSettings { IsAspNetCore = true, DefaultPropertyNameHandling = PropertyNameHandling.CamelCase, SwaggerRoute = $"/swagger/v1/swagger.json", SwaggerUiRoute = $"/swagger/v1", }; app.UseSwaggerUi(typeof(Startup).Assembly, swaggerSettings); app.UseMvc(); }
public SwaggerUiIndexMiddleware(OwinMiddleware next, string indexPath, SwaggerUiOwinSettings settings) : base(next) { _indexPath = indexPath; _settings = 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 IAppBuilder UseSwaggerUi( this IAppBuilder 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 IAppBuilder UseSwaggerUi( this IAppBuilder app, IEnumerable<Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { if (controllerTypes != null) app.Use<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.Use<RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.Use<SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileSystem = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.SwaggerUi") }); app.UseStageMarker(PipelineStage.MapHandler); 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 IAppBuilder UseSwaggerUi( this IAppBuilder 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 IAppBuilder UseSwaggerUi( this IAppBuilder app, IEnumerable<Assembly> webApiAssemblies, SwaggerUiOwinSettings settings) { var controllerTypes = webApiAssemblies.SelectMany(WebApiToSwaggerGenerator.GetControllerClasses); return app.UseSwaggerUi(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings)); }