internal static void PopulateFrom(this PartialSchema partialSchema, Schema schema)
        {
            if (schema == null)
            {
                return;
            }

            partialSchema.Type   = schema.Type;
            partialSchema.Format = schema.Format;

            if (schema.Items != null)
            {
                // TODO: Handle jagged primitive array and error on jagged object array
                partialSchema.Items = new PartialSchema();
                partialSchema.Items.PopulateFrom(schema.Items);
            }

            partialSchema.Default          = schema.Default;
            partialSchema.Maximum          = schema.Maximum;
            partialSchema.ExclusiveMaximum = schema.ExclusiveMaximum;
            partialSchema.Minimum          = schema.Minimum;
            partialSchema.ExclusiveMinimum = schema.ExclusiveMinimum;
            partialSchema.MaxLength        = schema.MaxLength;
            partialSchema.MinLength        = schema.MinLength;
            partialSchema.Pattern          = schema.Pattern;
            partialSchema.MaxItems         = schema.MaxItems;
            partialSchema.MinItems         = schema.MinItems;
            partialSchema.UniqueItems      = schema.UniqueItems;
            partialSchema.Enum             = schema.Enum;
            partialSchema.MultipleOf       = schema.MultipleOf;
        }
예제 #2
0
        internal static void PopulateFrom(this PartialSchema partialSchema, Schema schema)
        {
            if (schema == null)
            {
                return;
            }
            partialSchema.Type   = schema.Type;
            partialSchema.Format = schema.Format;
            if (schema.Items != null)
            {
                partialSchema.Items = new PartialSchema();
                partialSchema.Items.PopulateFrom(schema.Items);
                partialSchema.CollectionFormat = "multi";
            }

            partialSchema.Default          = schema.Default;
            partialSchema.Maximum          = schema.Maximum;
            partialSchema.ExclusiveMaximum = schema.ExclusiveMaximum;
            partialSchema.Minimum          = schema.Minimum;
            partialSchema.ExclusiveMinimum = schema.ExclusiveMinimum;
            partialSchema.MaxLength        = schema.MaxLength;
            partialSchema.MinLength        = schema.MinLength;
            partialSchema.Pattern          = schema.Pattern;
            partialSchema.MaxItems         = schema.MaxItems;
            partialSchema.MinItems         = schema.MinItems;
            partialSchema.UniqueItems      = schema.UniqueItems;
            partialSchema.Enum             = schema.Enum;
            partialSchema.MultipleOf       = schema.MultipleOf;
        }
예제 #3
0
        public void PopulateFrom_Null()
        {
            var    partSchema = new PartialSchema();
            Schema nullSchema = null;

            Assert.DoesNotThrow(() => partSchema.PopulateFrom(nullSchema));
        }
예제 #4
0
 void AddSchemaFor(PartialSchema type, Schema schema)
 {
     type.Type   = schema.Type;
     type.Format = schema.Format;
     if (schema.Items != null)
     {
         type.Items = new PartialSchema();
         AddSchemaFor(type.Items, schema.Items);
     }
 }
예제 #5
0
        public void PopulateFrom_Simple()
        {
            var partSchema = new PartialSchema();
            var schema     = new Schema {
                pattern = "abc"
            };

            partSchema.PopulateFrom(schema);
            Assert.AreEqual(schema.pattern, partSchema.pattern);
        }