diff --git a/.editorconfig b/.editorconfig index 2ce28b2..4f0a442 100644 --- a/.editorconfig +++ b/.editorconfig @@ -183,6 +183,8 @@ visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public # .NET Diagnostic # ############################### +[*.{cs,vb}] + # Simplify name dotnet_diagnostic.IDE0001.severity = warning diff --git a/src/Shop.Core/Extensions/JsonExtensions.cs b/src/Shop.Core/Extensions/JsonExtensions.cs index d264466..d0f41a3 100644 --- a/src/Shop.Core/Extensions/JsonExtensions.cs +++ b/src/Shop.Core/Extensions/JsonExtensions.cs @@ -8,7 +8,8 @@ namespace Shop.Core.Extensions; public static class JsonExtensions { - private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions().Configure(); + private static readonly Lazy LazyOptions = + new(() => new JsonSerializerOptions().Configure(), isThreadSafe: true); /// /// Converts a JSON string to an object of type T. @@ -17,7 +18,7 @@ public static class JsonExtensions /// The JSON string to deserialize. /// The deserialized object of type T. public static T FromJson(this string value) => - value != null ? JsonSerializer.Deserialize(value, JsonOptions) : default; + value != null ? JsonSerializer.Deserialize(value, LazyOptions.Value) : default; /// /// Converts an object to JSON string. @@ -26,7 +27,7 @@ public static class JsonExtensions /// The object to convert. /// The JSON string representation of the object. public static string ToJson(this T value) => - value != null ? JsonSerializer.Serialize(value, JsonOptions) : default; + value != null ? JsonSerializer.Serialize(value, LazyOptions.Value) : default; /// /// Configures the JsonSerializerOptions instance. diff --git a/src/Shop.PublicApi/Extensions/ServicesCollectionExtensions.cs b/src/Shop.PublicApi/Extensions/ServicesCollectionExtensions.cs index 8f7f9d7..f73c447 100644 --- a/src/Shop.PublicApi/Extensions/ServicesCollectionExtensions.cs +++ b/src/Shop.PublicApi/Extensions/ServicesCollectionExtensions.cs @@ -35,7 +35,16 @@ internal static class ServicesCollectionExtensions { Version = "v1", Title = "Shop (e-commerce)", - Description = "ASP.NET Core C# CQRS Event Sourcing, REST API, DDD, SOLID Principles and Clean Architecture" + Description = "ASP.NET Core C# CQRS Event Sourcing, REST API, DDD, SOLID Principles and Clean Architecture", + Contact = new OpenApiContact + { + Name = "Jean Gatto", + Email = "jean_gatto@hotmail.com" + }, + License = new OpenApiLicense + { + Name = "MIT License" + } }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";