Skip to content

Commit 34c2c8f

Browse files
VCST-1735: Update Swashbuckle to version 7.2.0 (#2868)
1 parent 807e039 commit 34c2c8f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/VirtoCommerce.Platform.Web/Swagger/CustomSwaggerGenerator.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Diagnostics;
33
using System.Reflection;
4+
using System.Threading.Tasks;
45
using Microsoft.AspNetCore.Mvc.ApiExplorer;
56
using Microsoft.OpenApi.Models;
67
using Swashbuckle.AspNetCore.Swagger;
@@ -12,7 +13,7 @@ namespace VirtoCommerce.Platform.Web.Swagger
1213
/// <summary>
1314
/// Generate swagger schema ids for schema refs depending on document name
1415
/// </summary>
15-
public class CustomSwaggerGenerator : ISwaggerProvider
16+
public class CustomSwaggerGenerator : IAsyncSwaggerProvider
1617
{
1718
private readonly SwaggerGenerator _swaggerGenerator;
1819
private readonly SchemaGeneratorOptions _schemaGeneratorOptions;
@@ -30,10 +31,10 @@ public CustomSwaggerGenerator(SwaggerGeneratorOptions options, IApiDescriptionGr
3031
_swaggerGenerator = new SwaggerGenerator(options, apiDescriptionsProvider, schemaGenerator);
3132
}
3233

33-
public OpenApiDocument GetSwagger(string documentName, string host = null, string basePath = null)
34+
public Task<OpenApiDocument> GetSwaggerAsync(string documentName, string host = null, string basePath = null)
3435
{
3536
SetSchemaIdSelector(documentName);
36-
return _swaggerGenerator.GetSwagger(documentName, host, basePath);
37+
return _swaggerGenerator.GetSwaggerAsync(documentName, host, basePath);
3738
}
3839

3940
private void SetSchemaIdSelector(string documentName)

src/VirtoCommerce.Platform.Web/Swagger/SwaggerServiceCollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static void AddSwagger(this IServiceCollection services, IConfiguration c
118118
// Unfortunately, we can't use .CustomSchemaIds, because it changes schema ids for all documents (impossible to change ids depending on document name).
119119
// But we need this, because PlatformUI document should contain ref schema ids as type.FullName to avoid conflict with same type names in different modules.
120120
// As a solution we use custom swagger generator that catches document name and generates schema ids depending on it.
121-
services.AddTransient<ISwaggerProvider, CustomSwaggerGenerator>();
121+
services.AddTransient<IAsyncSwaggerProvider, CustomSwaggerGenerator>();
122122

123123
//This is important line switches the SwaggerGenerator to use the Newtonsoft contract resolver that uses the globally registered PolymorphJsonContractResolver
124124
//to propagate up to the resulting OpenAPI schema the derived types instead of base domain types

src/VirtoCommerce.Platform.Web/VirtoCommerce.Platform.Web.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
3939
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
4040
<PackageReference Include="Scrutor" Version="5.0.2" />
41-
<PackageReference Include="Swashbuckle.AspNetCore" Version="[6.6.2,6.7)" />
42-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="[6.6.2,6.7)" />
41+
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
42+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.2.0" />
4343
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2" />
44-
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="[6.6.2,6.7)" />
45-
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="[6.6.2,6.7)" />
44+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="7.2.0" />
45+
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="7.2.0" />
4646
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="[8.0.1,9)" />
4747
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
4848
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />

0 commit comments

Comments
 (0)