Registering UdiJsonConverter globally so that we can migrate EntityBasic to Umbraco.Core
This commit is contained in:
@@ -3,10 +3,8 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Validation;
|
||||
using Umbraco.Core.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
@@ -28,7 +26,6 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
|
||||
[DataMember(Name = "udi")]
|
||||
[ReadOnly(true)]
|
||||
[JsonConverter(typeof(UdiJsonConverter))]
|
||||
public Udi Udi { get; set; }
|
||||
|
||||
[DataMember(Name = "icon")]
|
||||
@@ -61,7 +58,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// The path of the entity
|
||||
/// </summary>
|
||||
[DataMember(Name = "path")]
|
||||
public string Path { get; set; }
|
||||
public string Path { get; set; }
|
||||
/// <summary>
|
||||
/// A collection of extra data that is available for this specific entity/entity type
|
||||
/// </summary>
|
||||
@@ -6,9 +6,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using System.Buffers;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Web.Common.Formatters;
|
||||
|
||||
namespace Umbraco.Web.Common.ModelBinding
|
||||
@@ -32,6 +30,9 @@ namespace Umbraco.Web.Common.ModelBinding
|
||||
|
||||
var ss = jsonOptions.SerializerSettings; // Just use the defaults as base
|
||||
|
||||
// Register UdiJsonConverter globally
|
||||
ss.Converters.Add(new UdiJsonConverter());
|
||||
|
||||
// We need to ignore required attributes when serializing. E.g UserSave.ChangePassword. Otherwise the model is not model bound.
|
||||
ss.ContractResolver = new IgnoreRequiredAttributesResolver();
|
||||
return new IInputFormatter[]
|
||||
|
||||
Reference in New Issue
Block a user