mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
Remove support for PascalCase (Use camelCase in prod) (#1753)
This commit is contained in:
parent
605632fcb7
commit
d3673cdc85
@ -8,7 +8,6 @@ using Bit.Core;
|
|||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
using Bit.Core.Identity;
|
using Bit.Core.Identity;
|
||||||
using Bit.Core.Settings;
|
using Bit.Core.Settings;
|
||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using AspNetCoreRateLimit;
|
using AspNetCoreRateLimit;
|
||||||
using Stripe;
|
using Stripe;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
@ -18,7 +17,6 @@ using Microsoft.IdentityModel.Logging;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
|
|
||||||
#if !OSS
|
#if !OSS
|
||||||
using Bit.CommCore.Utilities;
|
using Bit.CommCore.Utilities;
|
||||||
@ -135,12 +133,6 @@ namespace Bit.Api
|
|||||||
{
|
{
|
||||||
config.Conventions.Add(new ApiExplorerGroupConvention());
|
config.Conventions.Add(new ApiExplorerGroupConvention());
|
||||||
config.Conventions.Add(new PublicApiControllersModelConvention());
|
config.Conventions.Add(new PublicApiControllersModelConvention());
|
||||||
}).AddNewtonsoftJson(options =>
|
|
||||||
{
|
|
||||||
if ((Environment.IsProduction() || Environment.IsEnvironment("QA")) && Configuration["swaggerGen"] != "true")
|
|
||||||
{
|
|
||||||
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSwagger(globalSettings);
|
services.AddSwagger(globalSettings);
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,10 +8,6 @@ namespace Bit.Api.Utilities
|
|||||||
{
|
{
|
||||||
var controllerNamespace = controller.ControllerType.Namespace;
|
var controllerNamespace = controller.ControllerType.Namespace;
|
||||||
var publicApi = controllerNamespace.Contains(".Public.");
|
var publicApi = controllerNamespace.Contains(".Public.");
|
||||||
if (publicApi)
|
|
||||||
{
|
|
||||||
controller.Filters.Add(new CamelCaseJsonResultFilterAttribute());
|
|
||||||
}
|
|
||||||
controller.Filters.Add(new ExceptionHandlerFilterAttribute(publicApi));
|
controller.Filters.Add(new ExceptionHandlerFilterAttribute(publicApi));
|
||||||
controller.Filters.Add(new ModelStateValidationFilterAttribute(publicApi));
|
controller.Filters.Add(new ModelStateValidationFilterAttribute(publicApi));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user