* Updated nuget packages + added migrations for OpenIddict - Currently can only be executed using unatttended installs * Added new Premigration concept - Migrations that always runs unattended before other migrations * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> --------- Co-authored-by: Zeegaan <skrivdetud@gmail.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Serialization;
|
|
using NJsonSchema.Generation;
|
|
using NJsonSchema.NewtonsoftJson.Generation;
|
|
|
|
/// <inheritdoc />
|
|
public class UmbracoJsonSchemaGenerator : JsonSchemaGenerator
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="UmbracoJsonSchemaGenerator" /> class.
|
|
/// </summary>
|
|
public UmbracoJsonSchemaGenerator()
|
|
: base(new NewtonsoftJsonSchemaGeneratorSettings()
|
|
{
|
|
AlwaysAllowAdditionalObjectProperties = true,
|
|
DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull,
|
|
FlattenInheritanceHierarchy = true,
|
|
IgnoreObsoleteProperties = true,
|
|
SerializerSettings = new JsonSerializerSettings()
|
|
{
|
|
ContractResolver = new WritablePropertiesOnlyResolver()
|
|
}
|
|
})
|
|
{
|
|
|
|
|
|
((NewtonsoftJsonSchemaGeneratorSettings)Settings).SerializerSettings.Converters.Add(new StringEnumConverter());
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
private class WritablePropertiesOnlyResolver : DefaultContractResolver
|
|
{
|
|
/// <inheritdoc />
|
|
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
|
=> base.CreateProperties(type, memberSerialization).Where(p => p.Writable).ToList();
|
|
}
|
|
}
|