Skip to content

Commit 53d0bbb

Browse files
author
Chris Young
committed
Merge branch 'release/7.1.0'
2 parents 4d014e7 + e626eed commit 53d0bbb

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

.DS_Store

-6 KB
Binary file not shown.

src/.DS_Store

-6 KB
Binary file not shown.

src/ArchitectNow.Web/Configuration/WebApiExtensions.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
using FluentValidation.AspNetCore;
55
using Microsoft.AspNetCore.Mvc;
66
using Microsoft.Extensions.DependencyInjection;
7-
using Newtonsoft.Json;
87
using Newtonsoft.Json.Converters;
98
using Newtonsoft.Json.Serialization;
109

1110
namespace ArchitectNow.Web.Configuration
1211
{
1312
public static class WebApiExtensions
1413
{
15-
public static void ConfigureApi(this IServiceCollection services, FluentValidationOptions fluentValidationOptions, Action<MvcOptions> configureMvc = null, Action<MvcJsonOptions> configureJson = null)
14+
public static void ConfigureApi(this IServiceCollection services, FluentValidationOptions fluentValidationOptions, Action<MvcOptions> configureMvc = null, Action<MvcJsonOptions> configureJson = null, Action<IMvcBuilder> configureMvcBuilder = null)
1615
{
1716
/*************************
1817
* IConfiguration is not available yet
@@ -33,16 +32,14 @@ public static void ConfigureApi(this IServiceCollection services, FluentValidati
3332
var camelCasePropertyNamesContractResolver = new CamelCasePropertyNamesContractResolver();
3433

3534
settings.ContractResolver = camelCasePropertyNamesContractResolver;
36-
settings.Converters = new JsonConverter[]
37-
{
38-
new IsoDateTimeConverter(),
39-
new StringEnumConverter(true)
40-
};
35+
settings.Converters.Add(new IsoDateTimeConverter());
36+
settings.Converters.Add(new StringEnumConverter(true));
4137

4238
configureJson?.Invoke(options);
4339
});
4440

45-
41+
configureMvcBuilder?.Invoke(mvcBuilder);
42+
4643
if (fluentValidationOptions.Enabled)
4744
{
4845
mvcBuilder.AddFluentValidation(configuration => fluentValidationOptions.Configure?.Invoke(configuration));

src/ArchitectNow.Web/StartupSample.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.AspNetCore.Antiforgery;
1010
using Microsoft.AspNetCore.Builder;
1111
using Microsoft.AspNetCore.Hosting;
12+
using Microsoft.AspNetCore.Mvc;
1213
using Microsoft.Extensions.Configuration;
1314
using Microsoft.Extensions.DependencyInjection;
1415
using Microsoft.Extensions.Logging;
@@ -40,7 +41,10 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
4041

4142
services.ConfigureJwt(_configuration, ConfigureSecurityKey);
4243

43-
services.ConfigureApi(new FluentValidationOptions {Enabled = true});
44+
services.ConfigureApi(new FluentValidationOptions {Enabled = true}, configureMvcBuilder: builder =>
45+
{
46+
builder.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
47+
});
4448

4549
services.ConfigureAutomapper(expression => { });
4650

0 commit comments

Comments
 (0)