예제 #1
0
 /// <summary>Adds the Swagger generator 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 UseSwagger(
     this IApplicationBuilder app,
     IEnumerable <Type> controllerTypes,
     SwaggerSettings settings)
 {
     return(app.UseSwagger(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings)));
 }
예제 #2
0
 /// <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 generator settings.</param>
 /// <returns>The app builder.</returns>
 public static IApplicationBuilder UseSwagger(
     this IApplicationBuilder app,
     Assembly webApiAssembly,
     SwaggerSettings settings)
 {
     return(app.UseSwagger(new[] { webApiAssembly }, settings));
 }
예제 #3
0
 /// <summary>Initializes a new instance of the <see cref="SwaggerMiddleware"/> class.</summary>
 /// <param name="nextDelegate">The next delegate.</param>
 /// <param name="path">The path.</param>
 /// <param name="controllerTypes">The controller types.</param>
 /// <param name="settings">The settings.</param>
 /// <param name="schemaGenerator">The schema generator.</param>
 public SwaggerMiddleware(RequestDelegate nextDelegate, string path, IEnumerable <Type> controllerTypes, SwaggerSettings settings, SwaggerJsonSchemaGenerator schemaGenerator)
 {
     _nextDelegate    = nextDelegate;
     _path            = path;
     _controllerTypes = controllerTypes;
     _settings        = settings;
     _schemaGenerator = schemaGenerator;
 }
예제 #4
0
 /// <summary>Adds the Swagger generator 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 UseSwagger(
     this IApplicationBuilder app,
     IEnumerable <Type> controllerTypes,
     SwaggerSettings settings,
     SwaggerJsonSchemaGenerator schemaGenerator)
 {
     app.UseMiddleware <SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator);
     return(app);
 }
예제 #5
0
        /// <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 generator settings.</param>
        /// <returns>The app builder.</returns>
        public static IApplicationBuilder UseSwagger(
            this IApplicationBuilder app,
            IEnumerable <Assembly> webApiAssemblies,
            SwaggerSettings settings)
        {
            var controllerTypes = webApiAssemblies.SelectMany(WebApiToSwaggerGenerator.GetControllerClasses);

            return(app.UseSwagger(controllerTypes, settings));
        }
예제 #6
0
        /// <summary>Adds the Swagger generator that uses Api Description to perform Swagger generation.</summary>
        /// <param name="app">The app.</param>
        /// <param name="configure">Configure the Swagger settings.</param>
        /// <param name="schemaGenerator">The schema generator.</param>
        public static IApplicationBuilder UseSwaggerWithApiExplorer(
            this IApplicationBuilder app,
            Action <SwaggerSettings <AspNetCoreToSwaggerGeneratorSettings> > configure = null,
            SwaggerJsonSchemaGenerator schemaGenerator = null)
        {
            var settings = new SwaggerSettings <AspNetCoreToSwaggerGeneratorSettings>();

            configure?.Invoke(settings);
            return(app.UseMiddleware <AspNetCoreToSwaggerMiddleware>(settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings)));
        }
예제 #7
0
        /// <summary>Adds the Swagger generator 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 settings.</param>
        public static IApplicationBuilder UseSwagger(
            this IApplicationBuilder app,
            IEnumerable <Type> controllerTypes,
            Action <SwaggerSettings> configure = null)
        {
            var settings = new SwaggerSettings();

            configure?.Invoke(settings);
            return(app.UseSwagger(controllerTypes, settings, new SwaggerJsonSchemaGenerator(settings)));
        }
예제 #8
0
        /// <summary>Adds the Swagger generator 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 UseSwagger(
            this IApplicationBuilder app,
            IEnumerable <Type> controllerTypes,
            Action <SwaggerSettings <WebApiToSwaggerGeneratorSettings> > configure = null,
            SwaggerJsonSchemaGenerator schemaGenerator = null)
        {
            var settings = new SwaggerSettings <WebApiToSwaggerGeneratorSettings>();

            configure?.Invoke(settings);
            app.UseMiddleware <WebApiToSwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings));
            return(app);
        }