/// <summary> /// Add the provided JSON schema as an option for the oneOf property of this JSON schema. /// </summary> /// <param name="oneOfOption"></param> /// <returns></returns> public JsonSchema AddOneOf(JsonSchema oneOfOption) { if (oneOfOption == null) { throw new ArgumentNullException(nameof(oneOfOption)); } if (OneOf == null) { OneOf = new List <JsonSchema>(); } OneOf.Add(oneOfOption); return(this); }
internal OneOfDefinition(MappingToken definition) : base(definition) { foreach (var definitionPair in definition) { var definitionKey = definitionPair.Key.AssertString($"{TemplateConstants.Definition} key"); switch (definitionKey.Value) { case TemplateConstants.OneOf: var oneOf = definitionPair.Value.AssertSequence(TemplateConstants.OneOf); foreach (var oneOfItem in oneOf) { var reference = oneOfItem.AssertString(TemplateConstants.OneOf); OneOf.Add(reference.Value); } break; default: definitionKey.AssertUnexpectedValue($"{TemplateConstants.Definition} key"); break; } } }