The settings for UseSwaggerUi.
Inheritance: SwaggerOwinSettings
Exemplo n.º 1
0
 /// <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));
 }
Exemplo n.º 2
0
 /// <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));
 }
Exemplo n.º 3
0
        /// <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)));
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        /// <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;
        }
Exemplo n.º 6
0
 public SwaggerUiIndexMiddleware(RequestDelegate nextDelegate, string indexPath, SwaggerUiOwinSettings settings)
 {
     _nextDelegate = nextDelegate;
     _indexPath    = indexPath;
     _settings     = settings;
 }
Exemplo n.º 7
0
 /// <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));
 }
Exemplo n.º 8
0
 public SwaggerUiIndexMiddleware(RequestDelegate nextDelegate, string indexPath, SwaggerUiOwinSettings settings)
 {
     _nextDelegate = nextDelegate;
     _indexPath = indexPath;
     _settings = settings;
 }
Exemplo n.º 9
0
 /// <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));
 }
Exemplo n.º 10
0
 /// <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);
 }
Exemplo n.º 11
0
        /// <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;
        }
Exemplo n.º 12
0
 /// <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);
 }