<PackageReference Include="NJsonSchema" Version="0.1.5470.35375" />

JsonProperty

public class JsonProperty : JsonSchemaBase
using Newtonsoft.Json; namespace NJsonSchema.DraftV4 { public class JsonProperty : JsonSchemaBase { private JsonSchemaBase _parent; [JsonIgnore] public string Key { get; set; } [JsonIgnore] public JsonSchemaBase Parent { get { return _parent; } internal set { bool flag = _parent == null; _parent = value; if (flag && InitialIsRequired) IsRequired = InitialIsRequired; } } [JsonIgnore] public bool IsRequired { get { return Parent.RequiredProperties.Contains(Key); } set { if (Parent == null) InitialIsRequired = value; else if (value) { if (!Parent.RequiredProperties.Contains(Key)) Parent.RequiredProperties.Add(Key); } else if (Parent.RequiredProperties.Contains(Key)) { Parent.RequiredProperties.Remove(Key); } } } [JsonIgnore] internal bool InitialIsRequired { get; set; } internal static JsonProperty FromJsonSchema(string key, JsonSchemaBase type) { string value = JsonConvert.SerializeObject(type); JsonProperty jsonProperty = JsonConvert.DeserializeObject<JsonProperty>(value); jsonProperty.Key = key; return jsonProperty; } } }