/// <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 IAppBuilder UseSwaggerUi( this IAppBuilder app, IEnumerable<Type> controllerTypes, Action<SwaggerUiSettings> configure = null) { var settings = new SwaggerUiSettings(); configure?.Invoke(settings); return app.UseSwaggerUi(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings)); }
public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, Action <SwaggerUiSettings> configure = null) { var settings = new SwaggerUiSettings(); settings.DocumentPath = "/swagger/v1/swagger.json"; configure?.Invoke(settings); app.UseMiddleware <RedirectToIndexMiddleware>(settings.ActualSwaggerUiPath, settings.ActualSwaggerDocumentPath, settings.TransformToExternalPath); app.UseMiddleware <SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiPath + "/index.html", settings, "NSwag.AspNetCore.SwaggerUi.index.html"); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiPath), FileProvider = new EmbeddedFileProvider(typeof(NSwagApplicationBuilderExtensions).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 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, SwaggerUiSettings 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, "NSwag.AspNet.Owin.SwaggerUi.index.html"); 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; }
public static void ConfigureSwagger(this IApplicationBuilder app, Assembly assembly) { var swaggerUiOwinSettings = new SwaggerUiSettings { DefaultPropertyNameHandling = PropertyNameHandling.CamelCase, Title = "ArchitectNow.ApiStarter", SwaggerRoute = "/api/docs/v1/swagger.json", SwaggerUiRoute = "/api/docs", UseJsonEditor = true, //Set to false if you want to manually type in the Json FlattenInheritanceHierarchy = true, IsAspNetCore = true }; swaggerUiOwinSettings.DocumentProcessors.Add(new SecurityDefinitionAppender("Authorization", new SwaggerSecurityScheme { Type = SwaggerSecuritySchemeType.ApiKey, Name = "Authorization", In = SwaggerSecurityApiKeyLocation.Header }) ); app.UseSwaggerUi(assembly, swaggerUiOwinSettings); }
public static IAppBuilder UseSwaggerUi( this IAppBuilder app, IEnumerable <Type> controllerTypes, Action <SwaggerUiSettings <WebApiOpenApiDocumentGeneratorSettings> > configure = null) { var settings = new SwaggerUiSettings <WebApiOpenApiDocumentGeneratorSettings>(); configure?.Invoke(settings); if (controllerTypes != null) { app.Use <OpenApiDocumentMiddleware>(settings.ActualSwaggerDocumentPath, controllerTypes, settings); } app.Use <RedirectToIndexMiddleware>(settings.ActualSwaggerUiPath, settings.ActualSwaggerDocumentPath, settings.TransformToExternalPath); app.Use <SwaggerUiIndexMiddleware <WebApiOpenApiDocumentGeneratorSettings> >(settings.ActualSwaggerUiPath + "/index.html", settings, "NSwag.AspNet.Owin.SwaggerUi.index.html"); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiPath), FileSystem = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.SwaggerUi") }); app.UseStageMarker(PipelineStage.MapHandler); return(app); }
static IApplicationBuilder UseDefaultSwaggerBuilderLocal(IApplicationBuilder app, SwaggerSettings swaggerSettings, SwaggerUiSettings swaggerUiSettings) => app .UseSwagger(option => {
public static IApplicationBuilder UseDefaultSwaggerBuilder(this IApplicationBuilder app, SwaggerSettings swaggerSettings, SwaggerUiSettings swaggerUiSettings, string environmentName) {
/// <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, SwaggerUiSettings settings) { return(app.UseSwaggerUi(null, settings, null)); }
protected virtual void SwaggerUiSetting(SwaggerUiSettings setting) { }
public CustomSwaggerGenOptions(IOptionsSnapshot <SwaggerUiSettings> swaggerUiConfig) { _swaggerUiSettings = swaggerUiConfig.Value; }
public SwaggerUiIndexMiddleware(OwinMiddleware next, string indexPath, SwaggerUiSettings settings) : base(next) { _indexPath = indexPath; _settings = settings; }