Datatype configuration refactor (#13605)

* Moved refactor from V12 based branch

* Remove obsolete config property to avoid obsoletion warnings

* Clean up test models

* Make the datatype API a little less confusing by introducing explicit models for create and update

* Remame "Configuration" to "Data" to make FE happy :)

* Safeguard deserialization of empty configs

* Less strict number handling for deserialization

* Prepare for data type config migrations

* Attempt to have contextual config serializers

* Update OpenAPI spec with (temporary) data type controller

* Fix unit tests

* Update compat suppressions (allow breakage for datatype and configuration editor)

* Make the duplicate JsonObjectConverter implementation private
This commit is contained in:
Kenn Jacobsen
2022-12-21 14:29:59 +01:00
committed by GitHub
parent a1ef0903c9
commit a8f070d834
71 changed files with 1448 additions and 854 deletions

View File

@@ -41,25 +41,43 @@ public class NestedContentTests
var dataType1 = new DataType(editor, serializer)
{
Id = 1,
Configuration = new NestedContentConfiguration
{
MinItems = 1,
MaxItems = 1,
ContentTypes = new[] { new NestedContentConfiguration.ContentType { Alias = "contentN1" } },
},
Id = 1
};
dataType1.ConfigurationData = dataType1.Editor!.GetConfigurationEditor()
.FromConfigurationObject(
new NestedContentConfiguration
{
MinItems = 1,
MaxItems = 1,
ContentTypes = new[] { new NestedContentConfiguration.ContentType { Alias = "contentN1" } },
},
serializer);
var configuration = dataType1.ConfigurationObject as NestedContentConfiguration;
Assert.NotNull(configuration);
Assert.AreEqual(1, configuration.MinItems);
Assert.AreEqual(1, configuration.MaxItems);
Assert.AreEqual(1, configuration.ContentTypes!.Length);
Assert.AreEqual("contentN1", configuration.ContentTypes.First().Alias);
var dataType2 = new DataType(editor, serializer)
{
Id = 2,
Configuration = new NestedContentConfiguration
{
MinItems = 1,
MaxItems = 99,
ContentTypes = new[] { new NestedContentConfiguration.ContentType { Alias = "contentN1" } },
},
Id = 2
};
dataType2.ConfigurationData = dataType2.Editor!.GetConfigurationEditor()
.FromConfigurationObject(
new NestedContentConfiguration
{
MinItems = 1,
MaxItems = 99,
ContentTypes = new[] { new NestedContentConfiguration.ContentType { Alias = "contentN1" } },
},
serializer);
configuration = dataType2.ConfigurationObject as NestedContentConfiguration;
Assert.NotNull(configuration);
Assert.AreEqual(1, configuration.MinItems);
Assert.AreEqual(99, configuration.MaxItems);
Assert.AreEqual(1, configuration.ContentTypes!.Length);
Assert.AreEqual("contentN1", configuration.ContentTypes.First().Alias);
var dataType3 =
new DataType(