1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

Remove support for PascalCase (Use camelCase in prod) (#1753)

This commit is contained in:
Oscar Hinton 2021-12-09 13:38:18 +00:00 committed by GitHub
parent 605632fcb7
commit d3673cdc85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 42 deletions

View File

@ -8,7 +8,6 @@ using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Identity;
using Bit.Core.Settings;
using Newtonsoft.Json.Serialization;
using AspNetCoreRateLimit;
using Stripe;
using Bit.Core.Utilities;
@ -18,7 +17,6 @@ using Microsoft.IdentityModel.Logging;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using System.Collections.Generic;
using System;
#if !OSS
using Bit.CommCore.Utilities;
@ -135,12 +133,6 @@ namespace Bit.Api
{
config.Conventions.Add(new ApiExplorerGroupConvention());
config.Conventions.Add(new PublicApiControllersModelConvention());
}).AddNewtonsoftJson(options =>
{
if ((Environment.IsProduction() || Environment.IsEnvironment("QA")) && Configuration["swaggerGen"] != "true")
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
}
});
services.AddSwagger(globalSettings);

View File

@ -1,30 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Bit.Api.Utilities
{
public class CamelCaseJsonResultFilterAttribute : IAsyncResultFilter
{
private static JsonSerializerSettings _jsonSerializerSettings;
static CamelCaseJsonResultFilterAttribute()
{
_jsonSerializerSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
}
public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
if (context.Result is JsonResult jsonResult)
{
context.Result = new JsonResult(jsonResult.Value, _jsonSerializerSettings);
}
await next();
}
}
}

View File

@ -8,10 +8,6 @@ namespace Bit.Api.Utilities
{
var controllerNamespace = controller.ControllerType.Namespace;
var publicApi = controllerNamespace.Contains(".Public.");
if (publicApi)
{
controller.Filters.Add(new CamelCaseJsonResultFilterAttribute());
}
controller.Filters.Add(new ExceptionHandlerFilterAttribute(publicApi));
controller.Filters.Add(new ModelStateValidationFilterAttribute(publicApi));
}