Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Fix tests for `net8.0`.
  • Loading branch information
martincostello committed May 1, 2024
1 parent 850b3a7 commit 1724d53
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/Swashbuckle.AspNetCore.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public static void AddingSchemaFilterTypes_WhenConfiguringOptions_DifferentInsta
options.SchemaFilter<TestSchemaFilter>();
options.SchemaFilter<TestSchemaFilter>();

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public static void AddingParameterFilterTypes_WhenConfiguringOptions_DifferentIn
options.ParameterFilter<TestParameterFilter>();
options.ParameterFilter<TestParameterFilter>();

using var serviceProvider = new ServiceCollection().BuildServiceProvider();

var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions(
Options.Create(options),
null,
serviceProvider,
webhostingEnvironment);
var swaggerGeneratorOptions = new SwaggerGeneratorOptions();

Expand Down Expand Up @@ -103,9 +105,11 @@ public static void AddingRequestBodyFilterTypes_WhenConfiguringOptions_Different
options.RequestBodyFilter<TestRequestBodyFilter>();
options.RequestBodyFilter<TestRequestBodyFilter>();

using var serviceProvider = new ServiceCollection().BuildServiceProvider();

var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions(
Options.Create(options),
null,
serviceProvider,
webhostingEnvironment);
var swaggerGeneratorOptions = new SwaggerGeneratorOptions();

Expand Down Expand Up @@ -150,9 +154,11 @@ public static void AddingOperationFilterTypes_WhenConfiguringOptions_DifferentIn
options.OperationFilter<TestOperationFilter>();
options.OperationFilter<TestOperationFilter>();

using var serviceProvider = new ServiceCollection().BuildServiceProvider();

var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions(
Options.Create(options),
null,
serviceProvider,
webhostingEnvironment);
var swaggerGeneratorOptions = new SwaggerGeneratorOptions();

Expand Down Expand Up @@ -197,9 +203,11 @@ public static void AddingDocumentFilterTypes_WhenConfiguringOptions_DifferentIns
options.DocumentFilter<TestDocumentFilter>();
options.DocumentFilter<TestDocumentFilter>();

using var serviceProvider = new ServiceCollection().BuildServiceProvider();

var configureSwaggerGeneratorOptions = new ConfigureSwaggerGeneratorOptions(
Options.Create(options),
null,
serviceProvider,
webhostingEnvironment);
var swaggerGeneratorOptions = new SwaggerGeneratorOptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ public class WeatherForecastController : ControllerBase
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DotNetSwaggerPath>$([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration)_$(TargetFramework)', 'dotnet-swagger.dll'))</DotNetSwaggerPath>
Expand Down
4 changes: 1 addition & 3 deletions test/WebSites/CustomDocumentSerializer/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Swashbuckle.AspNetCore.Swagger;

namespace CustomDocumentSerializer;

public class Startup
Expand All @@ -24,7 +22,7 @@ public void ConfigureServices(IServiceCollection services)
});
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();

Expand Down

0 comments on commit 1724d53

Please sign in to comment.