1
0
mirror of https://github.com/bitwarden/server synced 2026-02-22 04:13:43 +00:00

[deps] Billing: Update swashbuckle-aspnetcore monorepo to v10 (major) (#6729)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Derek Nance <dnance@bitwarden.com>
This commit is contained in:
renovate[bot]
2026-02-10 11:11:44 -05:00
committed by GitHub
parent cda8527c7d
commit 065d971dc4
21 changed files with 121 additions and 109 deletions

View File

@@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.23.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.0" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,5 @@
using System.Text.Json;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Bit.SharedWeb.Swagger;
@@ -18,8 +17,9 @@ public class ActionNameOperationFilter : IOperationFilter
if (!context.ApiDescription.ActionDescriptor.RouteValues.TryGetValue("action", out var action)) return;
if (string.IsNullOrEmpty(action)) return;
operation.Extensions.Add("x-action-name", new OpenApiString(action));
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add("x-action-name", new JsonNodeExtension(action));
// We can't do case changes in the codegen templates, so we also add the snake_case version of the action name
operation.Extensions.Add("x-action-name-snake-case", new OpenApiString(JsonNamingPolicy.SnakeCaseLower.ConvertName(action)));
operation.Extensions.Add("x-action-name-snake-case", new JsonNodeExtension(JsonNamingPolicy.SnakeCaseLower.ConvertName(action)));
}
}

View File

@@ -1,4 +1,4 @@
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Bit.SharedWeb.Swagger;
@@ -15,19 +15,22 @@ public class CheckDuplicateOperationIdsDocumentFilter(bool printDuplicates = tru
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
var operationIdMap = new Dictionary<string, List<(string Path, OpenApiPathItem PathItem, OperationType Method, OpenApiOperation Operation)>>();
var operationIdMap = new Dictionary<string, List<(string Path, IOpenApiPathItem PathItem, HttpMethod Method, OpenApiOperation Operation)>>();
foreach (var (path, pathItem) in swaggerDoc.Paths)
{
foreach (var operation in pathItem.Operations)
if (pathItem.Operations is null) continue;
foreach (var (method, operation) in pathItem.Operations)
{
if (!operationIdMap.TryGetValue(operation.Value.OperationId, out var list))
var operationId = operation.OperationId ?? string.Empty;
if (!operationIdMap.TryGetValue(operationId, out var list))
{
list = [];
operationIdMap[operation.Value.OperationId] = list;
operationIdMap[operationId] = list;
}
list.Add((path, pathItem, operation.Key, operation.Value));
list.Add((path, pathItem, method, operation));
}
}
@@ -57,11 +60,15 @@ public class CheckDuplicateOperationIdsDocumentFilter(bool printDuplicates = tru
{
Console.Write($" {method.ToString().ToUpper()} {path}");
if (operation.Extensions is null) continue;
if (operation.Extensions.TryGetValue("x-source-file", out var sourceFile) && operation.Extensions.TryGetValue("x-source-line", out var sourceLine))
if (operation.Extensions.TryGetValue("x-source-file", out var sourceFile)
&& operation.Extensions.TryGetValue("x-source-line", out var sourceLine)
&& sourceFile is JsonNodeExtension sourceFileNodeExt
&& sourceLine is JsonNodeExtension sourceLineNodeExt)
{
var sourceFileString = ((Microsoft.OpenApi.Any.OpenApiString)sourceFile).Value;
var sourceLineString = ((Microsoft.OpenApi.Any.OpenApiInteger)sourceLine).Value;
var sourceFileString = sourceFileNodeExt.Node.ToString();
var sourceLineString = sourceLineNodeExt.Node.ToString();
Console.WriteLine($" {sourceFileString}:{sourceLineString}");
}

View File

@@ -2,7 +2,7 @@
using System.Text.Json;
using Bit.Core.Utilities;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Bit.SharedWeb.Swagger;
@@ -13,7 +13,7 @@ namespace Bit.SharedWeb.Swagger;
/// </summary>
public class EncryptedStringSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
{
if (context.Type == null || schema.Properties == null)
return;
@@ -30,9 +30,9 @@ public class EncryptedStringSchemaFilter : ISchemaFilter
// Convert prop.Name to camelCase for JSON schema property lookup
var jsonPropName = JsonNamingPolicy.CamelCase.ConvertName(prop.Name);
if (schema.Properties.TryGetValue(jsonPropName, out var value))
if (schema.Properties.TryGetValue(jsonPropName, out var value) && value is OpenApiSchema innerSchema)
{
value.Format = "x-enc-string";
innerSchema.Format = "x-enc-string";
}
}
}

View File

@@ -1,5 +1,5 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using System.Text.Json.Nodes;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Bit.SharedWeb.Swagger;
@@ -14,13 +14,15 @@ namespace Bit.SharedWeb.Swagger;
/// </remarks>
public class EnumSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
{
if (context.Type.IsEnum)
if (context.Type.IsEnum && schema is OpenApiSchema openApiSchema)
{
var array = new OpenApiArray();
array.AddRange(Enum.GetNames(context.Type).Select(n => new OpenApiString(n)));
schema.Extensions.Add("x-enum-varnames", array);
var array = new JsonArray();
foreach (var name in Enum.GetNames(context.Type)) array.Add(name);
openApiSchema.Extensions ??= new Dictionary<string, IOpenApiExtension>();
openApiSchema.Extensions.Add("x-enum-varnames", new JsonNodeExtension(array));
}
}
}

View File

@@ -1,7 +1,7 @@
#nullable enable
using System.Diagnostics;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Bit.SharedWeb.Swagger;
@@ -16,7 +16,8 @@ public class GitCommitDocumentFilter : IDocumentFilter
{
if (!string.IsNullOrEmpty(GitCommit))
{
swaggerDoc.Extensions.Add("x-git-commit", new Microsoft.OpenApi.Any.OpenApiString(GitCommit));
swaggerDoc.Extensions ??= new Dictionary<string, IOpenApiExtension>();
swaggerDoc.Extensions.Add("x-git-commit", new JsonNodeExtension(GitCommit));
}
}

View File

@@ -4,8 +4,7 @@ using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.CompilerServices;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Bit.SharedWeb.Swagger;
@@ -24,8 +23,9 @@ public class SourceFileLineOperationFilter : IOperationFilter
if (fileName != null && lineNumber > 0)
{
// Also add the information as extensions, so other tools can use it in the future
operation.Extensions.Add("x-source-file", new OpenApiString(fileName));
operation.Extensions.Add("x-source-line", new OpenApiInteger(lineNumber));
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add("x-source-file", new JsonNodeExtension(fileName));
operation.Extensions.Add("x-source-line", new JsonNodeExtension(lineNumber));
}
}

View File

@@ -80,7 +80,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using StackExchange.Redis;
using Swashbuckle.AspNetCore.SwaggerGen;
using NoopRepos = Bit.Core.Repositories.Noop;
@@ -847,19 +847,9 @@ public static class ServiceCollectionExtensions
});
// Add security requirement
config.AddSecurityRequirement(new OpenApiSecurityRequirement
config.AddSecurityRequirement((document) => new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = serverId
},
},
[ApiScopes.ApiOrganization]
}
[new OpenApiSecuritySchemeReference(serverId, document)] = [ApiScopes.ApiOrganization]
});
}
}