Example #1
0
        /// <exception cref="InvalidOperationException">Cyclic references detected.</exception>
        /// <exception cref="InvalidOperationException">The schema reference path has not been resolved.</exception>
        private JsonSchema4 GetActualSchema(IList <JsonSchema4> checkedSchemas)
        {
            if (checkedSchemas.Contains(this))
            {
                throw new InvalidOperationException("Cyclic references detected.");
            }

            if (SchemaReferencePath != null && SchemaReference == null)
            {
                throw new InvalidOperationException("The schema reference path '" + SchemaReferencePath + "' has not been resolved.");
            }

            if (HasSchemaReference)
            {
                checkedSchemas.Add(this);

                if (HasAllOfSchemaReference)
                {
                    return(AllOf.First().GetActualSchema(checkedSchemas));
                }

                return(SchemaReference.GetActualSchema(checkedSchemas));
            }

            return(this);
        }