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

JsonProperty

public class JsonProperty : JsonSchema4
using Newtonsoft.Json; namespace NJsonSchema { public class JsonProperty : JsonSchema4 { private JsonSchema4 _parent; [JsonIgnore] public string Key { get; set; } public override JsonSchema4 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, JsonSchema4 type) { string value = JsonConvert.SerializeObject(type); JsonProperty jsonProperty = JsonConvert.DeserializeObject<JsonProperty>(value); jsonProperty.Key = key; return jsonProperty; } } }