diff --git a/src/Swashbuckle.AspNetCore.Cli/Program.cs b/src/Swashbuckle.AspNetCore.Cli/Program.cs index 7b9de83524..e416e7bbae 100644 --- a/src/Swashbuckle.AspNetCore.Cli/Program.cs +++ b/src/Swashbuckle.AspNetCore.Cli/Program.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using System.Runtime.Loader; -using System.Threading; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; @@ -102,7 +101,7 @@ public static int Main(string[] args) ? Path.Combine(Directory.GetCurrentDirectory(), arg1) : null; - using (Stream stream = (outputPath != null ? File.OpenWrite(outputPath) : Console.OpenStandardOutput())) + using (Stream stream = outputPath != null ? File.OpenWrite(outputPath) : Console.OpenStandardOutput()) using (var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture)) { IOpenApiWriter writer; diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSchemaGeneratorOptionsTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSchemaGeneratorOptionsTests.cs index 3a4471c44e..006b798570 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSchemaGeneratorOptionsTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSchemaGeneratorOptionsTests.cs @@ -53,7 +53,9 @@ public static void AddingSchemaFilterTypes_WhenConfiguringOptions_DifferentInsta options.SchemaFilter(); options.SchemaFilter(); - var configureSchemaGeneratorOptions = new ConfigureSchemaGeneratorOptions(Options.Create(options), null); + using var serviceProvider = new ServiceCollection().BuildServiceProvider(); + + var configureSchemaGeneratorOptions = new ConfigureSchemaGeneratorOptions(Options.Create(options), serviceProvider); var schemaGeneratorOptions = new SchemaGeneratorOptions(); configureSchemaGeneratorOptions.Configure(schemaGeneratorOptions); diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSwaggerGeneratorOptionsTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSwaggerGeneratorOptionsTests.cs index ca6a1c809d..2a2522b945 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSwaggerGeneratorOptionsTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/ConfigureSwaggerGeneratorOptionsTests.cs @@ -56,9 +56,11 @@ public static void AddingParameterFilterTypes_WhenConfiguringOptions_DifferentIn options.ParameterFilter(); options.ParameterFilter(); + using var serviceProvider = new ServiceCollection().BuildServiceProvider(); + var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions( Options.Create(options), - null, + serviceProvider, webhostingEnvironment); var swaggerGeneratorOptions = new SwaggerGeneratorOptions(); @@ -103,9 +105,11 @@ public static void AddingRequestBodyFilterTypes_WhenConfiguringOptions_Different options.RequestBodyFilter(); options.RequestBodyFilter(); + using var serviceProvider = new ServiceCollection().BuildServiceProvider(); + var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions( Options.Create(options), - null, + serviceProvider, webhostingEnvironment); var swaggerGeneratorOptions = new SwaggerGeneratorOptions(); @@ -150,9 +154,11 @@ public static void AddingOperationFilterTypes_WhenConfiguringOptions_DifferentIn options.OperationFilter(); options.OperationFilter(); + using var serviceProvider = new ServiceCollection().BuildServiceProvider(); + var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions( Options.Create(options), - null, + serviceProvider, webhostingEnvironment); var swaggerGeneratorOptions = new SwaggerGeneratorOptions(); @@ -197,9 +203,11 @@ public static void AddingDocumentFilterTypes_WhenConfiguringOptions_DifferentIns options.DocumentFilter(); options.DocumentFilter(); + using var serviceProvider = new ServiceCollection().BuildServiceProvider(); + var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions( Options.Create(options), - null, + serviceProvider, webhostingEnvironment); var swaggerGeneratorOptions = new SwaggerGeneratorOptions(); diff --git a/test/WebSites/CustomDocumentSerializer/Controllers/WeatherForecastController.cs b/test/WebSites/CustomDocumentSerializer/Controllers/WeatherForecastController.cs index 8011057792..7ab0a08e73 100644 --- a/test/WebSites/CustomDocumentSerializer/Controllers/WeatherForecastController.cs +++ b/test/WebSites/CustomDocumentSerializer/Controllers/WeatherForecastController.cs @@ -11,13 +11,6 @@ public class WeatherForecastController : ControllerBase "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - [HttpGet] public IEnumerable Get() { diff --git a/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj b/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj index f3b09fb04f..997a07e351 100644 --- a/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj +++ b/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 enable enable $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration)_$(TargetFramework)', 'dotnet-swagger.dll')) diff --git a/test/WebSites/CustomDocumentSerializer/Startup.cs b/test/WebSites/CustomDocumentSerializer/Startup.cs index de730d2101..5ff5964356 100644 --- a/test/WebSites/CustomDocumentSerializer/Startup.cs +++ b/test/WebSites/CustomDocumentSerializer/Startup.cs @@ -1,5 +1,3 @@ -using Swashbuckle.AspNetCore.Swagger; - namespace CustomDocumentSerializer; public class Startup @@ -24,7 +22,7 @@ public void ConfigureServices(IServiceCollection services) }); } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + public void Configure(IApplicationBuilder app) { app.UseSwagger();