mirror of
https://github.com/bitwarden/server
synced 2026-02-15 16:05:37 +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:
@@ -1,8 +1,7 @@
|
||||
using Bit.SharedWeb.Swagger;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace SharedWeb.Test;
|
||||
@@ -13,7 +12,10 @@ public class ActionNameOperationFilterTest
|
||||
public void WithValidActionNameAddsActionNameExtensions()
|
||||
{
|
||||
// Arrange
|
||||
var operation = new OpenApiOperation();
|
||||
var operation = new OpenApiOperation
|
||||
{
|
||||
Extensions = new Dictionary<string, IOpenApiExtension>()
|
||||
};
|
||||
var actionDescriptor = new ActionDescriptor();
|
||||
actionDescriptor.RouteValues["action"] = "GetUsers";
|
||||
|
||||
@@ -22,7 +24,7 @@ public class ActionNameOperationFilterTest
|
||||
ActionDescriptor = actionDescriptor
|
||||
};
|
||||
|
||||
var context = new OperationFilterContext(apiDescription, null, null, null);
|
||||
var context = new OperationFilterContext(apiDescription, null, null, null, null);
|
||||
var filter = new ActionNameOperationFilter();
|
||||
|
||||
// Act
|
||||
@@ -32,20 +34,23 @@ public class ActionNameOperationFilterTest
|
||||
Assert.True(operation.Extensions.ContainsKey("x-action-name"));
|
||||
Assert.True(operation.Extensions.ContainsKey("x-action-name-snake-case"));
|
||||
|
||||
var actionNameExt = operation.Extensions["x-action-name"] as OpenApiString;
|
||||
var actionNameSnakeCaseExt = operation.Extensions["x-action-name-snake-case"] as OpenApiString;
|
||||
var actionNameExt = operation.Extensions["x-action-name"] as JsonNodeExtension;
|
||||
var actionNameSnakeCaseExt = operation.Extensions["x-action-name-snake-case"] as JsonNodeExtension;
|
||||
|
||||
Assert.NotNull(actionNameExt);
|
||||
Assert.NotNull(actionNameSnakeCaseExt);
|
||||
Assert.Equal("GetUsers", actionNameExt.Value);
|
||||
Assert.Equal("get_users", actionNameSnakeCaseExt.Value);
|
||||
Assert.Equal("GetUsers", actionNameExt.Node.ToString());
|
||||
Assert.Equal("get_users", actionNameSnakeCaseExt.Node.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithMissingActionRouteValueDoesNotAddExtensions()
|
||||
{
|
||||
// Arrange
|
||||
var operation = new OpenApiOperation();
|
||||
var operation = new OpenApiOperation
|
||||
{
|
||||
Extensions = new Dictionary<string, IOpenApiExtension>()
|
||||
};
|
||||
var actionDescriptor = new ActionDescriptor();
|
||||
// Not setting the "action" route value at all
|
||||
|
||||
@@ -54,7 +59,7 @@ public class ActionNameOperationFilterTest
|
||||
ActionDescriptor = actionDescriptor
|
||||
};
|
||||
|
||||
var context = new OperationFilterContext(apiDescription, null, null, null);
|
||||
var context = new OperationFilterContext(apiDescription, null, null, null, null);
|
||||
var filter = new ActionNameOperationFilter();
|
||||
|
||||
// Act
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Bit.SharedWeb.Swagger;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace SharedWeb.Test;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.SharedWeb.Swagger;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class EncryptedStringSchemaFilterTest
|
||||
{
|
||||
var schema = new OpenApiSchema
|
||||
{
|
||||
Properties = new Dictionary<string, OpenApiSchema> { { "secretKey", new() } }
|
||||
Properties = new Dictionary<string, IOpenApiSchema> { { "secretKey", new OpenApiSchema() } }
|
||||
};
|
||||
var context = new SchemaFilterContext(typeof(TestClass), null, null, null);
|
||||
var filter = new EncryptedStringSchemaFilter();
|
||||
@@ -37,7 +37,7 @@ public class EncryptedStringSchemaFilterTest
|
||||
{
|
||||
var schema = new OpenApiSchema
|
||||
{
|
||||
Properties = new Dictionary<string, OpenApiSchema> { { "username", new() } }
|
||||
Properties = new Dictionary<string, IOpenApiSchema> { { "username", new OpenApiSchema() } }
|
||||
};
|
||||
var context = new SchemaFilterContext(typeof(TestClass), null, null, null);
|
||||
var filter = new EncryptedStringSchemaFilter();
|
||||
@@ -50,7 +50,7 @@ public class EncryptedStringSchemaFilterTest
|
||||
{
|
||||
var schema = new OpenApiSchema
|
||||
{
|
||||
Properties = new Dictionary<string, OpenApiSchema> { { "wrong", new() } }
|
||||
Properties = new Dictionary<string, IOpenApiSchema> { { "wrong", new OpenApiSchema() } }
|
||||
};
|
||||
var context = new SchemaFilterContext(typeof(TestClass), null, null, null);
|
||||
var filter = new EncryptedStringSchemaFilter();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Bit.SharedWeb.Swagger;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace SharedWeb.Test;
|
||||
@@ -17,21 +16,27 @@ public class EnumSchemaFilterTest
|
||||
[Fact]
|
||||
public void SetsEnumVarNamesExtension()
|
||||
{
|
||||
var schema = new OpenApiSchema();
|
||||
var schema = new OpenApiSchema
|
||||
{
|
||||
Extensions = new Dictionary<string, IOpenApiExtension>()
|
||||
};
|
||||
var context = new SchemaFilterContext(typeof(TestEnum), null, null, null);
|
||||
var filter = new EnumSchemaFilter();
|
||||
filter.Apply(schema, context);
|
||||
|
||||
Assert.True(schema.Extensions.ContainsKey("x-enum-varnames"));
|
||||
var extensions = schema.Extensions["x-enum-varnames"] as OpenApiArray;
|
||||
var extensions = (schema.Extensions["x-enum-varnames"] as JsonNodeExtension).Node.AsArray();
|
||||
Assert.NotNull(extensions);
|
||||
Assert.Equal(["First", "Second", "Third"], extensions.Select(x => ((OpenApiString)x).Value));
|
||||
Assert.Equal(["First", "Second", "Third"], extensions.GetValues<string>().Select(x => x));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DoesNotSetExtensionForNonEnum()
|
||||
{
|
||||
var schema = new OpenApiSchema();
|
||||
var schema = new OpenApiSchema
|
||||
{
|
||||
Extensions = new Dictionary<string, IOpenApiExtension>()
|
||||
};
|
||||
var context = new SchemaFilterContext(typeof(string), null, null, null);
|
||||
var filter = new EnumSchemaFilter();
|
||||
filter.Apply(schema, context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Bit.SharedWeb.Swagger;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace SharedWeb.Test;
|
||||
@@ -9,15 +9,18 @@ public class GitCommitDocumentFilterTest
|
||||
[Fact]
|
||||
public void AddsGitCommitExtensionIfAvailable()
|
||||
{
|
||||
var doc = new OpenApiDocument();
|
||||
var doc = new OpenApiDocument
|
||||
{
|
||||
Extensions = new Dictionary<string, IOpenApiExtension>()
|
||||
};
|
||||
var context = new DocumentFilterContext(null, null, null);
|
||||
var filter = new GitCommitDocumentFilter();
|
||||
filter.Apply(doc, context);
|
||||
|
||||
Assert.True(doc.Extensions.ContainsKey("x-git-commit"));
|
||||
var ext = doc.Extensions["x-git-commit"] as Microsoft.OpenApi.Any.OpenApiString;
|
||||
var ext = doc.Extensions["x-git-commit"] as JsonNodeExtension;
|
||||
Assert.NotNull(ext);
|
||||
Assert.False(string.IsNullOrEmpty(ext.Value));
|
||||
Assert.False(string.IsNullOrEmpty(ext.Node.ToString()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Bit.SharedWeb.Swagger;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace SharedWeb.Test;
|
||||
@@ -16,18 +16,18 @@ public class SourceFileLineOperationFilterTest
|
||||
{
|
||||
var methodInfo = typeof(DummyController).GetMethod(nameof(DummyController.DummyMethod));
|
||||
var operation = new OpenApiOperation();
|
||||
var context = new OperationFilterContext(null, null, null, methodInfo);
|
||||
var context = new OperationFilterContext(null, null, null, null, methodInfo);
|
||||
var filter = new SourceFileLineOperationFilter();
|
||||
filter.Apply(operation, context);
|
||||
|
||||
Assert.True(operation.Extensions.ContainsKey("x-source-file"));
|
||||
Assert.True(operation.Extensions.ContainsKey("x-source-line"));
|
||||
var fileExt = operation.Extensions["x-source-file"] as Microsoft.OpenApi.Any.OpenApiString;
|
||||
var lineExt = operation.Extensions["x-source-line"] as Microsoft.OpenApi.Any.OpenApiInteger;
|
||||
var fileExt = operation.Extensions["x-source-file"] as JsonNodeExtension;
|
||||
var lineExt = operation.Extensions["x-source-line"] as JsonNodeExtension;
|
||||
Assert.NotNull(fileExt);
|
||||
Assert.NotNull(lineExt);
|
||||
|
||||
Assert.Equal(11, lineExt.Value);
|
||||
Assert.StartsWith("test/SharedWeb.Test/", fileExt.Value);
|
||||
Assert.Equal(11, (int)lineExt.Node);
|
||||
Assert.StartsWith("test/SharedWeb.Test/", fileExt.Node.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi;
|
||||
using NSubstitute;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
Reference in New Issue
Block a user