using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; using NJsonSchema.Generation; using NJsonSchema.NewtonsoftJson.Generation; /// public class UmbracoJsonSchemaGenerator : JsonSchemaGenerator { /// /// Initializes a new instance of the class. /// 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()); } /// private class WritablePropertiesOnlyResolver : DefaultContractResolver { /// protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) => base.CreateProperties(type, memberSerialization).Where(p => p.Writable).ToList(); } }